本文整理汇总了Java中javax.validation.ElementKind.BEAN属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.BEAN属性的具体用法?Java ElementKind.BEAN怎么用?Java ElementKind.BEAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.validation.ElementKind
的用法示例。
在下文中一共展示了ElementKind.BEAN属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: as
@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: beforeNode
@Override
public void beforeNode(Object obj, DescriptorPath path) {
if (path.getHeadNode().getKind() != ElementKind.BEAN) {
return;
}
BeanDescriptorNode node = path.getHeadNode().as(BeanDescriptorNode.class);
Named named = ReflectionHelper.findAnnotation(node.getBean().getClass(), Named.class);
Referenced referenced = ReflectionHelper.findAnnotation(node.getBean().getClass(), Referenced.class);
if (referenced != null) {
if (referenced.as().length == 0 && named == null) {
throw new IllegalStateException("The @Referenced annotation requires the @Named to also exist.");
}
ReferenceType type = referenced.type();
references.put(type, path.onlyInclude(ElementKind.BEAN));
}
}
示例3: callReferenceConstraints
private void callReferenceConstraints(Object obj, DescriptorPath path) {
DescriptorNode node = path.getHeadNode();
for (ReferenceConstraint<T> constraint : constraints) {
if (node.getClass().isAssignableFrom(constraint.getNodeType())) {
continue;
}
Annotation annotation;
Class<? extends Annotation> annClass = constraint.getAnnotationType();
if (node.getKind() == ElementKind.BEAN) {
annotation = ReflectionHelper.findAnnotation(obj.getClass(), annClass);
} else if (node.getKind() == ElementKind.PROPERTY) {
Method method = node.as(PropertyNode.class).getMethod();
annotation = ReflectionHelper.findAnnotation(method, annClass);
} else {
throw new IllegalStateException(node.getKind() + " is an unsupported type.");
}
if (annotation == null) {
continue;
}
this.violations.addAll(constraint.checkConstraint(annotation, obj, path, allowedRefs));
}
}
示例4: visitProperty
public Object visitProperty(Object nodeObject, Node node) {
Object next;
if (node.getKind() == ElementKind.PROPERTY) {
next = PropertyUtils.getProperty(nodeObject, node.getName());
}
else if (node.getKind() == ElementKind.BEAN) {
next = nodeObject;
}
else {
throw new UnsupportedOperationException("unknown node: " + node);
}
if (node.getName() != null) {
appendSeparator();
if (!isResource(nodeObject.getClass()) || isPrimaryKey(nodeObject.getClass(), node.getName())) {
// continue along attributes path or primary key on root
appendSourcePointer(node.getName());
}
else if (isAssociation(nodeObject.getClass(), node.getName())) {
appendSourcePointer("/data/relationships/");
appendSourcePointer(node.getName());
}
else {
appendSourcePointer("/data/attributes/");
appendSourcePointer(node.getName());
}
}
return next;
}
示例5: getKind
@Override
public ElementKind getKind() {
if (path == null) {
return ElementKind.BEAN;
} else {
return ElementKind.PROPERTY;
}
}
示例6: createBeanNode
/**
* create bean node.
*
* @param parent parent node
* @return new node implementation
*/
public static NodeImpl createBeanNode(final NodeImpl parent) {
return new NodeImpl( //
null, //
parent, //
false, //
null, //
null, //
ElementKind.BEAN, EMPTY_CLASS_ARRAY, //
null, //
null, //
null, //
null //
);
}
示例7: BeanNode
public BeanNode(String name,
Object key,
Object bean,
boolean isNamed) {
super(name, false, null, key, ElementKind.BEAN);
this.isNamed = isNamed;
this.bean = bean;
}