下面列出了怎么用java.lang.IllegalStateException的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public long receiveMessages(int sessionMode) throws Exception {
final Message message = consumer.receive(RECEIVE_TIMEOUT_MILLIS);
if (message == null) {
return ReceiverClient.noMessagePayload();
} else if (sessionMode == Session.CLIENT_ACKNOWLEDGE) {
message.acknowledge();
} else if (sessionMode == Session.SESSION_TRANSACTED) {
logger.warn("Acknowledging the transaction");
session.commit();
}
final int readBytes = getReadBytes((BytesMessage) message);
if (readBytes == PAYLOAD_SIZE || readBytes == -1) {
//can read the timestamp using the default endianness of the content strategy
return payloadBytes.getLong(0);
}
throw new IllegalStateException("the received message hasn't any benchmark payload");
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final ModelViewWithParis object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
if (!Objects.equals(style, object.getTag(R.id.epoxy_saved_view_style))) {
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
public void run() {
try {
StyleApplierUtils.Companion.assertSameAttributes(new ModelViewWithParisStyleApplier(object), style, DEFAULT_PARIS_STYLE);
}
catch(AssertionError e) {
throw new IllegalStateException("ModelViewWithParisModel_ model at position " + position + " has an invalid style:\n\n" + e.getMessage());
}
}
} );
}
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(10)) {
throw new IllegalStateException("A value is required for setArrayValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(12)) {
throw new IllegalStateException("A value is required for setClickListener");
}
if (!assignedAttributes_epoxyGeneratedModel.get(9)) {
throw new IllegalStateException("A value is required for setBooleanValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setStringValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(7)) {
throw new IllegalStateException("A value is required for setIntegerValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(11)) {
throw new IllegalStateException("A value is required for setListValue");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final StyleableModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
if (!Objects.equals(style, object.getTag(R.id.epoxy_saved_view_style))) {
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
public void run() {
try {
StyleApplierUtils.Companion.assertSameAttributes(new StyleableModelViewStyleApplier(object), style, DEFAULT_PARIS_STYLE);
}
catch(AssertionError e) {
throw new IllegalStateException("StyleableModelViewModel_ model at position " + position + " has an invalid style:\n\n" + e.getMessage());
}
}
} );
}
}
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
IllegalStateException object1 = new IllegalStateException();
harness.check(object1 != null);
harness.check(object1.toString(), "java.lang.IllegalStateException");
IllegalStateException object2 = new IllegalStateException("nothing happens");
harness.check(object2 != null);
harness.check(object2.toString(), "java.lang.IllegalStateException: nothing happens");
IllegalStateException object3 = new IllegalStateException((String)null);
harness.check(object3 != null);
harness.check(object3.toString(), "java.lang.IllegalStateException");
}
@Override
public final IllegalStateException canOnlyRemoveDeploymentsWhenUndeployed(final State state) {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), canOnlyRemoveDeploymentsWhenUndeployed$str(), state));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException getReaderAlreadyCalled() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), getReaderAlreadyCalled$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException getInputStreamAlreadyCalled() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), getInputStreamAlreadyCalled$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException getWriterAlreadyCalled() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), getWriterAlreadyCalled$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException getOutputStreamAlreadyCalled() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), getOutputStreamAlreadyCalled$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException asyncNotStarted() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), asyncNotStarted$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException responseAlreadyCommited() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), responseAlreadyCommited$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException contentHasBeenWritten() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), contentHasBeenWritten$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException sessionIsInvalid() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), sessionIsInvalid$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException asyncRequestAlreadyDispatched() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), asyncRequestAlreadyDispatched$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException startAsyncNotAllowed() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), startAsyncNotAllowed$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException notImplemented() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), notImplemented$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException asyncAlreadyStarted() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), asyncAlreadyStarted$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException noSession() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), noSession$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException streamNotInAsyncMode() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), streamNotInAsyncMode$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException streamNotReady() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), streamNotReady$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException listenerAlreadySet() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), listenerAlreadySet$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException moreThanOneDefaultErrorPage(final String defaultErrorPage, final String location) {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), moreThanOneDefaultErrorPage$str(), defaultErrorPage, location));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException servletContextAlreadyInitialized() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), servletContextAlreadyInitialized$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException asyncRequestAlreadyReturnedToContainer() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), asyncRequestAlreadyReturnedToContainer$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException filterNotFound(final String filterName, final String mapping) {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), filterNotFound$str(), filterName, mapping));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException noConfidentialPortAvailable() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), noConfidentialPortAvailable$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException listenerIsNotStarted() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), listenerIsNotStarted$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException pathWasNotSet() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), pathWasNotSet$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override
public final IllegalStateException multipartConfigNotPresent() {
final IllegalStateException result = new IllegalStateException(String.format(getLoggingLocale(), multipartConfigNotPresent$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}