javax.validation
Interface Path.Node

All Known Subinterfaces:
Path.BeanNode, Path.ConstructorNode, Path.CrossParameterNode, Path.MethodNode, Path.ParameterNode, Path.PropertyNode, Path.ReturnValueNode
Enclosing interface:
Path

public static interface Path.Node

Represents an element of a navigation path.


Method Summary
<T extends Path.Node>
T
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()
           
 

Method Detail

getName

String getName()
Returns the name of the element which the node represents:

Returns:
name of the element which the node represents

isInIterable

boolean isInIterable()
Returns:
true if the node represents an object contained in an Iterable or in a Map, false otherwise

getIndex

Integer getIndex()
Returns:
the index the node is placed in if contained in an array or List; null otherwise

getKey

Object getKey()
Returns:
the key the node is placed in if contained in a Map, null otherwise

getKind

ElementKind getKind()
The kind of element represented by the node. The following relationship between an ElementKind and its Node subtype exists:

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();
 [...]
 }
 

Returns:
the ElementKind
Since:
1.1

as

<T extends Path.Node> T as(Class<T> nodeType)
Narrows the type of this node down to the given type. The appropriate type should be checked before by calling getKind().

Type Parameters:
T - the type to narrow down to
Parameters:
nodeType - class object representing the descriptor type to narrow down to to
Returns:
this node narrowed down to the given type.
Throws:
ClassCastException - If this node is not assignable to the type T
Since:
1.1


Copyright © 2007-2013 Red Hat Inc. All Rights Reserved. Released under the Apache Software License 2.0.