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
Path.Node
.Modifier and Type | Field and Description |
---|---|
static String |
CROSS_PARAMETER_NODE_NAME |
static String |
ITERABLE_ELEMENT_NODE_NAME |
static String |
LIST_ELEMENT_NODE_NAME |
static String |
MAP_KEY_NODE_NAME |
static String |
MAP_VALUE_NODE_NAME |
static String |
RETURN_VALUE_NODE_NAME |
Modifier and Type | Method and Description |
---|---|
<T extends Path.Node> |
as(Class<T> nodeType)
Narrows the type of this node down to the given type.
|
String |
asString() |
int |
buildHashCode() |
static NodeImpl |
createBeanNode(NodeImpl parent) |
static NodeImpl |
createConstructorNode(String name,
NodeImpl parent,
Class<?>[] parameterTypes) |
static NodeImpl |
createContainerElementNode(String name,
NodeImpl parent) |
static NodeImpl |
createCrossParameterNode(NodeImpl parent) |
static NodeImpl |
createMethodNode(String name,
NodeImpl parent,
Class<?>[] parameterTypes) |
static NodeImpl |
createParameterNode(String name,
NodeImpl parent,
int parameterIndex) |
static NodeImpl |
createPropertyNode(String name,
NodeImpl parent) |
static NodeImpl |
createReturnValue(NodeImpl parent) |
boolean |
equals(Object obj) |
Class<?> |
getContainerClass() |
Integer |
getIndex() |
Object |
getKey() |
ElementKind |
getKind()
The kind of element represented by the node.
|
String |
getName()
Returns the name of the element which the node represents:
null if it is a leaf node which represents an entity / bean. |
int |
getParameterIndex() |
List<Class<?>> |
getParameterTypes() |
NodeImpl |
getParent() |
Integer |
getTypeArgumentIndex() |
Object |
getValue() |
int |
hashCode() |
boolean |
isInIterable() |
boolean |
isIterable() |
static NodeImpl |
makeIterable(NodeImpl node) |
static NodeImpl |
makeIterableAndSetIndex(NodeImpl node,
Integer index) |
static NodeImpl |
makeIterableAndSetMapKey(NodeImpl node,
Object key) |
static NodeImpl |
setPropertyValue(NodeImpl node,
Object value) |
static NodeImpl |
setTypeParameter(NodeImpl node,
Class<?> containerClass,
Integer typeArgumentIndex) |
String |
toString()
Returns a human-readable representation of this node.
|
public static final String RETURN_VALUE_NODE_NAME
public static final String CROSS_PARAMETER_NODE_NAME
public static final String ITERABLE_ELEMENT_NODE_NAME
public static final String LIST_ELEMENT_NODE_NAME
public static final String MAP_KEY_NODE_NAME
public static final String MAP_VALUE_NODE_NAME
public static NodeImpl createContainerElementNode(String name, NodeImpl parent)
public static NodeImpl createParameterNode(String name, NodeImpl parent, int parameterIndex)
public static NodeImpl createMethodNode(String name, NodeImpl parent, Class<?>[] parameterTypes)
public static NodeImpl createConstructorNode(String name, NodeImpl parent, Class<?>[] parameterTypes)
public static NodeImpl makeIterableAndSetIndex(NodeImpl node, Integer index)
public static NodeImpl setTypeParameter(NodeImpl node, Class<?> containerClass, Integer typeArgumentIndex)
public final String getName()
Path.Node
null
if it is a leaf node which represents an entity / bean.
In particular, the node representing the root object.ParameterNameProvider
for a method or constructor parameter.<cross-parameter>
for a method or constructor
cross-parameter.<return value>
for a method or constructor return
value.ValueExtractor
for a container
element; specifically, the literal <list element>
for elements
stored in a list, the literal <iterable element>
for elements
stored in an Iterable
, the literal <map key>
for the keys
stored in a Map
and the literal <map value>
for the values
stored in a Map
.
public final boolean isInIterable()
isInIterable
in interface Path.Node
true
if the node represents an object contained in
a multi-valued container such as Iterable
or Map
or an array,
false
otherwisepublic final boolean isIterable()
public final Integer getIndex()
public final Object getKey()
public Class<?> getContainerClass()
getContainerClass
in interface Path.BeanNode
getContainerClass
in interface Path.ContainerElementNode
getContainerClass
in interface Path.PropertyNode
Optional
, List
or Map
,
null
otherwisepublic Integer getTypeArgumentIndex()
getTypeArgumentIndex
in interface Path.BeanNode
getTypeArgumentIndex
in interface Path.ContainerElementNode
getTypeArgumentIndex
in interface Path.PropertyNode
Optional
, List
or
Map
, null
otherwisepublic final NodeImpl getParent()
public ElementKind getKind()
Path.Node
ElementKind
and its Node
subtype exists:
ElementKind.BEAN
: Path.BeanNode
ElementKind.PROPERTY
: Path.PropertyNode
ElementKind.METHOD
: Path.MethodNode
ElementKind.CONSTRUCTOR
: Path.ConstructorNode
ElementKind.PARAMETER
: Path.ParameterNode
ElementKind.CROSS_PARAMETER
: Path.CrossParameterNode
ElementKind.RETURN_VALUE
: Path.ReturnValueNode
ElementKind.CONTAINER_ELEMENT
: Path.ContainerElementNode
This is useful to narrow down the Node
type 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(); [...] }
public <T extends Path.Node> T as(Class<T> nodeType)
Path.Node
Path.Node.getKind()
.public List<Class<?>> getParameterTypes()
getParameterTypes
in interface Path.ConstructorNode
getParameterTypes
in interface Path.MethodNode
public int getParameterIndex()
getParameterIndex
in interface Path.ParameterNode
public Object getValue()
getValue
in interface ContainerElementNode
getValue
in interface PropertyNode
public String toString()
Path.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.
public final String asString()
public final int buildHashCode()
Copyright © 2021 JBoss by Red Hat. All rights reserved.