本文整理匯總了Java中javax.validation.Path.ParameterNode類的典型用法代碼示例。如果您正苦於以下問題:Java ParameterNode類的具體用法?Java ParameterNode怎麽用?Java ParameterNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ParameterNode類屬於javax.validation.Path包,在下文中一共展示了ParameterNode類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: as
import javax.validation.Path.ParameterNode; //導入依賴的package包/類
@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);
}
示例2: extractCategory
import javax.validation.Path.ParameterNode; //導入依賴的package包/類
/**
* 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();
}
示例3: getFirstParameterIndex
import javax.validation.Path.ParameterNode; //導入依賴的package包/類
private int getFirstParameterIndex( Iterator<Node> node ){
ignoreMethodName( node );
ParameterNode parameterNode = node.next().as(ParameterNode.class);
return parameterNode.getParameterIndex();
}