org.wildfly.common.Assert.impossibleSwitchCase()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(166)

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

Assert.impossibleSwitchCase介绍

[英]Return an exception indicating that the current switch case was intended to be unreachable.
[中]返回一个异常,该异常指示当前开关的情况是不可访问的。

代码示例

代码示例来源:origin: wildfly/wildfly

private String passwordAlgorithm(final String mechanismName) {
  switch (mechanismName) {
    case SaslMechanismInformation.Names.DIGEST_SHA:     return DigestPassword.ALGORITHM_DIGEST_SHA;
    case SaslMechanismInformation.Names.DIGEST_SHA_256: return DigestPassword.ALGORITHM_DIGEST_SHA_256;
    case SaslMechanismInformation.Names.DIGEST_SHA_384: return DigestPassword.ALGORITHM_DIGEST_SHA_384;
    case SaslMechanismInformation.Names.DIGEST_SHA_512: return DigestPassword.ALGORITHM_DIGEST_SHA_512;
    case SaslMechanismInformation.Names.DIGEST_SHA_512_256: return DigestPassword.ALGORITHM_DIGEST_SHA_512_256;
    case SaslMechanismInformation.Names.DIGEST_MD5:     return DigestPassword.ALGORITHM_DIGEST_MD5;
    default: throw Assert.impossibleSwitchCase(mechanismName);
  }
}

代码示例来源:origin: wildfly/wildfly

private String getAction(final int bit) {
    switch (bit) {
      case ACTION_BIND: return "bind";
      case ACTION_REBIND: return "rebind";
      case ACTION_UNBIND: return "unbind";
      case ACTION_LOOKUP: return "lookup";
      case ACTION_LIST: return "list";
      case ACTION_LIST_BINDINGS: return "listBindings";
      case ACTION_CREATE_SUBCONTEXT: return "createSubcontext";
      case ACTION_DESTROY_SUBCONTEXT: return "destroySubcontext";
      case ACTION_ADD_NAMING_LISTENER: return "addNamingListener";
      default: throw Assert.impossibleSwitchCase(bit);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public synchronized Object get() throws InterruptedException, ExecutionException {
  for (;;) switch (status) {
    case ST_RUNNING: wait(); break;
    case ST_CANCELLED: throw EjbLogger.ROOT_LOGGER.taskWasCancelled();
    case ST_FAILED: throw new ExecutionException(failed);
    case ST_DONE: return result;
    default: throw Assert.impossibleSwitchCase(status);
  }
}

代码示例来源:origin: wildfly/wildfly

void addDependent(Dependency task) {
  synchronized (lock) {
    switch (state) {
      case WAITING:
      case RUNNING: runner.dependents.add(task); return;
      case FAILED: return;
      case DONE: break; // fall out of lock
      default: throw Assert.impossibleSwitchCase(state);
    }
  }
  task.dependencyFinished();
}

代码示例来源:origin: wildfly/wildfly

void join(final AtomicReference<State> stateRef, final URI location, final SimpleTransactionControl control) throws IllegalStateException {
  State newState;
  switch (status) {
    case Status.STATUS_ACTIVE: newState = new Active(location, control); break;
    case Status.STATUS_MARKED_ROLLBACK: newState = new RollbackOnly(location, control); break;
    default: throw Assert.impossibleSwitchCase(status);
  }
  if (stateRef.compareAndSet(this, newState)) {
    return;
  } else {
    stateRef.get().join(stateRef, location, control);
  }
}

代码示例来源:origin: wildfly/wildfly

/** {@inheritDoc} */
@SuppressWarnings({ "unchecked" })
public final T get() throws InterruptedException, ExecutionException {
  synchronized (AsyncFutureTask.this) {
    final Status status = await();
    switch (status) {
      case CANCELLED:
        throw Messages.msg.operationCancelled();
      case FAILED:
        throw Messages.msg.operationFailed((Throwable) result);
      case COMPLETE: return (T) result;
      default: throw Assert.impossibleSwitchCase(status);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

/** {@inheritDoc} */
@SuppressWarnings({ "unchecked" })
public final T getUninterruptibly() throws CancellationException, ExecutionException {
  synchronized (AsyncFutureTask.this) {
    final Status status = awaitUninterruptibly();
    switch (status) {
      case CANCELLED:
        throw Messages.msg.operationCancelled();
      case FAILED:
        throw Messages.msg.operationFailed((Throwable) result);
      case COMPLETE: return (T) result;
      default: throw Assert.impossibleSwitchCase(status);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

/** {@inheritDoc} */
@SuppressWarnings({ "unchecked" })
public final T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  synchronized (AsyncFutureTask.this) {
    final Status status = await(timeout, unit);
    switch (status) {
      case CANCELLED:
        throw Messages.msg.operationCancelled();
      case FAILED:
        throw Messages.msg.operationFailed((Throwable) result);
      case COMPLETE: return (T) result;
      case WAITING:
        throw Messages.msg.operationTimedOut();
      default: throw Assert.impossibleSwitchCase(status);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

/** {@inheritDoc} */
@SuppressWarnings({ "unchecked" })
public final T getUninterruptibly(final long timeout, final TimeUnit unit) throws CancellationException, ExecutionException, TimeoutException {
  synchronized (AsyncFutureTask.this) {
    final Status status = awaitUninterruptibly(timeout, unit);
    switch (status) {
      case CANCELLED:
        throw Messages.msg.operationCancelled();
      case FAILED:
        throw Messages.msg.operationFailed((Throwable) result);
      case COMPLETE: return (T) result;
      case WAITING:
        throw Messages.msg.operationTimedOut();
      default: throw Assert.impossibleSwitchCase(status);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException {
    switch (state) {
      case INITIAL_STATE:
        int length = message.length;
        if (length == 0) {
          // need initial challenge
          return NO_BYTES;
        } else {
          // sanity check
          if (length > 1020) {
            throw saslAnonymous.mechAuthenticationNameTooLong().toSaslException();
          }
          String name = new String(message, StandardCharsets.UTF_8);
          if (name.length() > 255) {
            throw saslAnonymous.mechAuthenticationNameTooLong().toSaslException();
          }
          final AnonymousAuthorizationCallback callback = new AnonymousAuthorizationCallback(name);
          handleCallbacks(callback);
          if (! callback.isAuthorized()) {
            throw saslAnonymous.mechAnonymousAuthorizationDenied().toSaslException();
          }
          negotiationComplete();
          return null;
        }
    }
    throw Assert.impossibleSwitchCase(state);
  }
}

代码示例来源:origin: wildfly/wildfly

return b.toArray();
throw Assert.impossibleSwitchCase(state);

代码示例来源:origin: wildfly/wildfly

@Override
  protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException {
    HashMap<String, byte[]> parsedChallenge;
    try {
      parsedChallenge = parseResponse(message, charset, true, saslDigest);
    } catch (AuthenticationMechanismException e) {
      throw e.toSaslException();
    }
    while(true) {
      switch (state) {
        case STEP_TWO:
          noteChallengeData(parsedChallenge);
          setNegotiationState(STEP_FOUR);
          return createResponse(parsedChallenge);
        case STEP_FOUR:
          if (parsedChallenge.containsKey("nonce")) {
            saslDigest.trace("Server requested re-authentication");
            state = STEP_TWO;
            continue;
          }
          checkResponseAuth(parsedChallenge);
          negotiationComplete();
          return null;
      }
      throw Assert.impossibleSwitchCase(state);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

return getNullReference();
default:
  throw Assert.impossibleSwitchCase(type);

代码示例来源:origin: wildfly/wildfly

return getNullReference();
default:
  throw Assert.impossibleSwitchCase(type);

代码示例来源:origin: wildfly/wildfly

return getNullReference();
default:
  throw Assert.impossibleSwitchCase(type);

代码示例来源:origin: wildfly/wildfly

throw Assert.impossibleSwitchCase(state);
} catch (AuthenticationMechanismException e) {
  throw e.toSaslException();

代码示例来源:origin: wildfly/wildfly

@Override
protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException {
  switch (state) {
    case STEP_ONE:
      if (message != null && message.length != 0) {
        throw saslDigest.mechInitialChallengeMustBeEmpty().toSaslException();
      }
      setNegotiationState(STEP_THREE);
      return generateChallenge();
    case STEP_THREE:
      if (message == null || message.length == 0) {
        throw saslDigest.mechClientRefusesToInitiateAuthentication().toSaslException();
      }
      // parse digest response
      HashMap<String, byte[]> parsedDigestResponse;
      try {
        parsedDigestResponse = parseResponse(message, charset, false, saslDigest);
      } catch (AuthenticationMechanismException e) {
        throw e.toSaslException();
      }
      noteDigestResponseData(parsedDigestResponse);
      // validate
      byte[] response = validateDigestResponse(parsedDigestResponse);
      negotiationComplete();
      return response;
  }
  throw Assert.impossibleSwitchCase(state);
}

代码示例来源:origin: wildfly/wildfly

throw Assert.impossibleSwitchCase(state);
} catch (AuthenticationMechanismException e) {
  throw e.toSaslException();

代码示例来源:origin: wildfly/wildfly

throw Assert.impossibleSwitchCase(state);
} catch (AuthenticationMechanismException e) {
  throw e.toSaslException();

代码示例来源:origin: wildfly/wildfly

throw Assert.impossibleSwitchCase(state);

相关文章