Class NodeImpl
java.lang.Object
org.hibernate.validator.internal.engine.path.NodeImpl
- All Implemented Interfaces:
Path.BeanNode,Path.ConstructorNode,Path.ContainerElementNode,Path.CrossParameterNode,Path.MethodNode,Path.Node,Path.ParameterNode,Path.PropertyNode,Path.ReturnValueNode,Serializable,ContainerElementNode,PropertyNode
public class NodeImpl
extends Object
implements Path.PropertyNode, Path.MethodNode, Path.ConstructorNode, Path.BeanNode, Path.ParameterNode, Path.ReturnValueNode, Path.CrossParameterNode, Path.ContainerElementNode, PropertyNode, ContainerElementNode, Serializable
Immutable implementation of a
Path.Node.- Author:
- Hardy Ferentschik, Gunnar Morling, Guillaume Smet
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T extends Path.Node>
TNarrows the type of this node down to the given type.final StringasString()final intstatic NodeImplcreateBeanNode(NodeImpl parent) static NodeImplcreateConstructorNode(String name, NodeImpl parent, Class<?>[] parameterTypes) static NodeImplcreateContainerElementNode(String name, NodeImpl parent) static NodeImplcreateCrossParameterNode(NodeImpl parent) static NodeImplcreateMethodNode(String name, NodeImpl parent, Class<?>[] parameterTypes) static NodeImplcreateParameterNode(String name, NodeImpl parent, int parameterIndex) static NodeImplcreatePropertyNode(String name, NodeImpl parent) static NodeImplcreateReturnValue(NodeImpl parent) booleanClass<?>final IntegergetIndex()final ObjectgetKey()getKind()The kind of element represented by the node.final StringgetName()Returns the name of the element which the node represents:nullif it is a leaf node which represents an entity / bean.intfinal NodeImplgetValue()inthashCode()final booleanfinal booleanstatic NodeImplmakeIterable(NodeImpl node) static NodeImplmakeIterableAndSetIndex(NodeImpl node, Integer index) static NodeImplmakeIterableAndSetMapKey(NodeImpl node, Object key) static NodeImplsetPropertyValue(NodeImpl node, Object value) static NodeImplsetTypeParameter(NodeImpl node, Class<?> containerClass, Integer typeArgumentIndex) toString()Returns a human-readable representation of this node.
-
Field Details
-
RETURN_VALUE_NODE_NAME
- See Also:
-
CROSS_PARAMETER_NODE_NAME
- See Also:
-
ITERABLE_ELEMENT_NODE_NAME
- See Also:
-
LIST_ELEMENT_NODE_NAME
- See Also:
-
MAP_KEY_NODE_NAME
- See Also:
-
MAP_VALUE_NODE_NAME
- See Also:
-
-
Method Details
-
createPropertyNode
-
createContainerElementNode
-
createParameterNode
-
createCrossParameterNode
-
createMethodNode
-
createConstructorNode
-
createBeanNode
-
createReturnValue
-
makeIterable
-
makeIterableAndSetIndex
-
makeIterableAndSetMapKey
-
setPropertyValue
-
setTypeParameter
-
getName
Description copied from interface:Path.NodeReturns the name of the element which the node represents:nullif it is a leaf node which represents an entity / bean. In particular, the node representing the root object.- The property name for a property.
- The method name for a method.
- The unqualified name of the type declaring the constructor for a constructor.
- The parameter named as defined by the
ParameterNameProviderfor a method or constructor parameter. - The literal
<cross-parameter>for a method or constructor cross-parameter. - The literal
<return value>for a method or constructor return value. - The node name as defined by the
ValueExtractorfor a container element; specifically, the literal<list element>for elements stored in a list, the literal<iterable element>for elements stored in anIterable, the literal<map key>for the keys stored in aMapand the literal<map value>for the values stored in aMap.
-
isInIterable
public final boolean isInIterable()- Specified by:
isInIterablein interfacePath.Node- Returns:
trueif the node represents an object contained in a multi-valued container such asIterableorMapor an array,falseotherwise
-
isIterable
public final boolean isIterable() -
getIndex
-
getKey
-
getContainerClass
- Specified by:
getContainerClassin interfacePath.BeanNode- Specified by:
getContainerClassin interfacePath.ContainerElementNode- Specified by:
getContainerClassin interfacePath.PropertyNode- Returns:
- the type of the container the node is placed in, if contained in a
container type such as
Optional,ListorMap,nullotherwise
-
getTypeArgumentIndex
- Specified by:
getTypeArgumentIndexin interfacePath.BeanNode- Specified by:
getTypeArgumentIndexin interfacePath.ContainerElementNode- Specified by:
getTypeArgumentIndexin interfacePath.PropertyNode- Returns:
- the index of the type argument affected by the violated constraint, if
contained in a generic container type such as
Optional,ListorMap,nullotherwise
-
getParent
-
getKind
Description copied from interface:Path.NodeThe kind of element represented by the node. The following relationship between anElementKindand itsNodesubtype exists:ElementKind.BEAN:Path.BeanNodeElementKind.PROPERTY:Path.PropertyNodeElementKind.METHOD:Path.MethodNodeElementKind.CONSTRUCTOR:Path.ConstructorNodeElementKind.PARAMETER:Path.ParameterNodeElementKind.CROSS_PARAMETER:Path.CrossParameterNodeElementKind.RETURN_VALUE:Path.ReturnValueNodeElementKind.CONTAINER_ELEMENT:Path.ContainerElementNode
This is useful to narrow down the
Nodetype and access node specific information:switch(node.getKind() { case METHOD: name = node.getName(); params = node.as(MethodNode.class).getParameterTypes(); case PARAMETER: index = node.as(ParameterNode.class).getParameterIndex(); [...] } -
as
Description copied from interface:Path.NodeNarrows the type of this node down to the given type. The appropriate type should be checked before by callingPath.Node.getKind(). -
getParameterTypes
- Specified by:
getParameterTypesin interfacePath.ConstructorNode- Specified by:
getParameterTypesin interfacePath.MethodNode- Returns:
- the list of parameter types
-
getParameterIndex
public int getParameterIndex()- Specified by:
getParameterIndexin interfacePath.ParameterNode- Returns:
- the parameter index in the method or constructor definition
-
getValue
- Specified by:
getValuein interfaceContainerElementNode- Specified by:
getValuein interfacePropertyNode- Returns:
- Returns the value of the bean property represented by this node.
-
toString
Description copied from interface:Path.NodeReturns a human-readable representation of this node.Clients should not rely on any specific structure of the returned value. Instead they should obtain any required information by calling the methods on this interface and its sub-types.
-
asString
-
buildHashCode
public final int buildHashCode() -
hashCode
public int hashCode() -
equals
-