public static interface Path.Node
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.
|
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. |
boolean |
isInIterable() |
String |
toString()
Returns a human-readable representation of this node.
|
String getName()
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
.
boolean isInIterable()
true
if the node represents an object contained in
a multi-valued container such as Iterable
or Map
or an array,
false
otherwiseInteger getIndex()
List
or any other container supporting indexed access, null
otherwiseObject getKey()
Map
or any
other container supporting keyed access, null
otherwiseElementKind getKind()
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(); [...] }
ElementKind
<T extends Path.Node> T as(Class<T> nodeType)
getKind()
.T
- the type to narrow down tonodeType
- class object representing the descriptor type to narrow down to
toClassCastException
- if this node is not assignable to the type T
String toString()
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.
Copyright © 2019 JBoss by Red Hat. All rights reserved.