Class NodeUtils


  • public class NodeUtils
    extends java.lang.Object
    A utility class to operate on a given Node.
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isArrayLengthFieldAccess​(Node node)
      Returns true iff node is a FieldAccessNode that is an access to an array's length.
      static boolean isBooleanTypeNode​(Node node)
      Returns true iff node corresponds to a boolean typed expression (either the primitive type boolean, or class type Boolean).
      static boolean isConstantBoolean​(Node n, boolean value)
      Returns true if the given node statically evaluates to value and has no side effects.
      static boolean isMethodInvocation​(Node node, javax.lang.model.element.ExecutableElement method, javax.annotation.processing.ProcessingEnvironment env)
      Returns true iff node is an invocation of the given method.
      static Node removeCasts​(Node node)
      Remove any TypeCastNodes wrapping a node, returning the operand nested within the type casts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NodeUtils

        public NodeUtils()
    • Method Detail

      • isBooleanTypeNode

        public static boolean isBooleanTypeNode​(Node node)
        Returns true iff node corresponds to a boolean typed expression (either the primitive type boolean, or class type Boolean).
        Returns:
        true iff node corresponds to a boolean typed expression (either the primitive type boolean, or class type Boolean)
      • isArrayLengthFieldAccess

        public static boolean isArrayLengthFieldAccess​(Node node)
        Returns true iff node is a FieldAccessNode that is an access to an array's length.
        Returns:
        true iff node is a FieldAccessNode that is an access to an array's length
      • isMethodInvocation

        public static boolean isMethodInvocation​(Node node,
                                                 javax.lang.model.element.ExecutableElement method,
                                                 javax.annotation.processing.ProcessingEnvironment env)
        Returns true iff node is an invocation of the given method.
      • isConstantBoolean

        public static boolean isConstantBoolean​(Node n,
                                                boolean value)
        Returns true if the given node statically evaluates to value and has no side effects.
        Parameters:
        n - a node
        value - the boolean value that the node is tested against
        Returns:
        true if the node is equivalent to a literal with value value
      • removeCasts

        public static Node removeCasts​(Node node)
        Remove any TypeCastNodes wrapping a node, returning the operand nested within the type casts.
        Parameters:
        node - a node
        Returns:
        node, but with any surrounding typecasts removed