java.lang.IllegalStateException类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(351)

本文整理了Java中java.lang.IllegalStateException类的一些代码示例,展示了IllegalStateException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IllegalStateException类的具体详情如下:
包路径:java.lang.IllegalStateException
类名称:IllegalStateException

IllegalStateException介绍

[英]Thrown when an action is attempted at a time when the VM is not in the correct state.
[中]在VM未处于正确状态时尝试操作时引发。

代码示例

代码示例来源:origin: iluwatar/java-design-patterns

  1. private ThreadSafeLazyLoadedIvoryTower() {
  2. // protect against instantiation via reflection
  3. if (instance == null) {
  4. instance = this;
  5. } else {
  6. throw new IllegalStateException("Already initialized.");
  7. }
  8. }

代码示例来源:origin: iluwatar/java-design-patterns

  1. /**
  2. * private constructor to prevent client from instantiating.
  3. */
  4. private ThreadSafeDoubleCheckLocking() {
  5. // to prevent instantiating by Reflection call
  6. if (instance != null) {
  7. throw new IllegalStateException("Already initialized.");
  8. }
  9. }

代码示例来源:origin: iluwatar/java-design-patterns

  1. @Override
  2. public void onError(Throwable throwable) {
  3. throw new IllegalStateException("Should not occur");
  4. }
  5. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private Exceptions() {
  3. throw new IllegalStateException("No instances!");
  4. }
  5. /**

代码示例来源:origin: ReactiveX/RxJava

  1. /** Helper class, no instances. */
  2. private RxJavaPlugins() {
  3. throw new IllegalStateException("No instances!");
  4. }
  5. }

代码示例来源:origin: ReactiveX/RxJava

  1. /**
  2. * Utility class.
  3. */
  4. private EndConsumerHelper() {
  5. throw new IllegalStateException("No instances!");
  6. }

代码示例来源:origin: square/okhttp

  1. public Builder allEnabledCipherSuites() {
  2. if (!tls) throw new IllegalStateException("no cipher suites for cleartext connections");
  3. this.cipherSuites = null;
  4. return this;
  5. }

代码示例来源:origin: square/okhttp

  1. @Override protected Handshake handshake() {
  2. if (delegate.call == null) {
  3. throw new IllegalStateException("Connection has not yet been established");
  4. }
  5. return delegate.handshake;
  6. }

代码示例来源:origin: square/okhttp

  1. public void setServerSocketFactory(ServerSocketFactory serverSocketFactory) {
  2. if (executor != null) {
  3. throw new IllegalStateException(
  4. "setServerSocketFactory() must be called before start()");
  5. }
  6. this.serverSocketFactory = serverSocketFactory;
  7. }

代码示例来源:origin: square/okhttp

  1. @Override public Headers trailers() throws IOException {
  2. if (state != STATE_CLOSED) {
  3. throw new IllegalStateException("too early; can't read the trailers yet");
  4. }
  5. return trailers != null ? trailers : Util.EMPTY_HEADERS;
  6. }

代码示例来源:origin: square/okhttp

  1. public Builder allEnabledTlsVersions() {
  2. if (!tls) throw new IllegalStateException("no TLS versions for cleartext connections");
  3. this.tlsVersions = null;
  4. return this;
  5. }

代码示例来源:origin: square/okhttp

  1. /**
  2. * @deprecated since OkHttp 3.13 all TLS-connections are expected to support TLS extensions.
  3. * In a future release setting this to true will be unnecessary and setting it to false will
  4. * have no effect.
  5. */
  6. public Builder supportsTlsExtensions(boolean supportsTlsExtensions) {
  7. if (!tls) throw new IllegalStateException("no TLS extensions for cleartext connections");
  8. this.supportsTlsExtensions = supportsTlsExtensions;
  9. return this;
  10. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private HalfSerializer() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private ObjectHelper() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private FlowableScalarXMap() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private Functions() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private Disposables() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private FlowableInternalHelper() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private BackpressureHelper() {
  3. throw new IllegalStateException("No instances!");
  4. }

代码示例来源:origin: ReactiveX/RxJava

  1. /** Utility class. */
  2. private BlockingHelper() {
  3. throw new IllegalStateException("No instances!");
  4. }

相关文章