当前位置: 首页>>代码示例>>Java>>正文


Java ElementKind.BEAN属性代码示例

本文整理汇总了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);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:18,代码来源:NodeImpl.java

示例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));
  }
}
 
开发者ID:cloudera,项目名称:cm_ext,代码行数:16,代码来源:ReferenceValidatorImpl.java

示例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));
  }
}
 
开发者ID:cloudera,项目名称:cm_ext,代码行数:25,代码来源:ReferenceValidatorImpl.java

示例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;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:30,代码来源:ConstraintViolationExceptionMapper.java

示例5: getKind

@Override
public ElementKind getKind() {
	if (path == null) {
		return ElementKind.BEAN;
	} else {
		return ElementKind.PROPERTY;
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:8,代码来源:ConstraintViolationImpl.java

示例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 //
  );
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:20,代码来源:NodeImpl.java

示例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;
}
 
开发者ID:cloudera,项目名称:cm_ext,代码行数:8,代码来源:DescriptorPathImpl.java


注:本文中的javax.validation.ElementKind.BEAN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。