Java 类javax.validation.Path.ParameterNode 实例源码

项目:gwt-bean-validators    文件:NodeImpl.java   
@SuppressWarnings("unchecked")
@Override
public <T extends Path.Node> T as(final Class<T> nodeType) throws ClassCastException { // NOPMD
  if (this.kind == ElementKind.BEAN && nodeType == BeanNode.class
      || this.kind == ElementKind.CONSTRUCTOR && nodeType == ConstructorNode.class
      || this.kind == ElementKind.CROSS_PARAMETER && nodeType == CrossParameterNode.class
      || this.kind == ElementKind.METHOD && nodeType == MethodNode.class
      || this.kind == ElementKind.PARAMETER && nodeType == ParameterNode.class
      || this.kind == ElementKind.PROPERTY && (nodeType == PropertyNode.class
          || nodeType == org.hibernate.validator.path.PropertyNode.class)
      || this.kind == ElementKind.RETURN_VALUE && nodeType == ReturnValueNode.class
      || this.kind == ElementKind.CONTAINER_ELEMENT && (nodeType == ContainerElementNode.class
          || nodeType == org.hibernate.validator.path.ContainerElementNode.class)) {
    return (T) this;
  }

  throw LOG.getUnableToNarrowNodeTypeException(this.getClass(), this.kind, nodeType);
}
项目:vraptor4    文件:MethodValidator.java   
/**
 * Returns the category for this constraint violation. By default, the category returned
 * is the full path for property. You can override this method if you prefer another strategy.
 */
protected String extractCategory(ValuedParameter[] params, ConstraintViolation<Object> violation) {
    Iterator<Node> path = violation.getPropertyPath().iterator();
    Node method = path.next();
    logger.debug("Constraint violation on method {}: {}", method, violation);

    StringBuilder cat = new StringBuilder();
    cat.append(params[path.next().as(ParameterNode.class).getParameterIndex()].getName());// parameter name

    while (path.hasNext()) {
        cat.append(".").append(path.next());
    }

    return cat.toString();
}
项目:hurraa    文件:CejugMethodValidator.java   
private int getFirstParameterIndex( Iterator<Node> node ){
    ignoreMethodName( node );
    ParameterNode parameterNode = node.next().as(ParameterNode.class);
    return parameterNode.getParameterIndex();
}