Class Name

java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.expr.Name
All Implemented Interfaces:
NodeWithIdentifier<Name>, NodeWithRange<Node>, NodeWithTokenRange<Node>, Observable, Visitable, HasParentNode<Node>, Cloneable

public class Name extends Node implements NodeWithIdentifier<Name>
A name that may consist of multiple identifiers. In other words: it.may.contain.dots.

The rightmost identifier is "identifier", The one to the left of it is "qualifier.identifier", etc.

You can construct one from a String with the name(...) method.

Author:
Julio Vilmar Gesser
See Also:
SimpleName
  • Constructor Details

    • Name

      public Name()
    • Name

      public Name(String identifier)
    • Name

      public Name(Name qualifier, String identifier)
    • Name

      public Name(TokenRange tokenRange, Name qualifier, String identifier)
      This constructor is used by the parser and is considered private.
  • Method Details

    • accept

      public <R,​ A> R accept(GenericVisitor<R,​A> v, A arg)
      Description copied from interface: Visitable
      Accept method for visitor support.
      Specified by:
      accept in interface Visitable
      Type Parameters:
      R - the type of the return value of the visitor
      A - the type the user argument passed to the visitor
      Parameters:
      v - the visitor implementation
      arg - the argument passed to the visitor (of type A)
      Returns:
      the result of the visit (of type R)
    • accept

      public <A> void accept(VoidVisitor<A> v, A arg)
      Description copied from interface: Visitable
      Accept method for visitor support.
      Specified by:
      accept in interface Visitable
      Type Parameters:
      A - the type the argument passed for the visitor
      Parameters:
      v - the visitor implementation
      arg - any value relevant for the visitor (of type A)
    • getIdentifier

      public String getIdentifier()
      Specified by:
      getIdentifier in interface NodeWithIdentifier<Name>
    • setIdentifier

      public Name setIdentifier(String identifier)
      Specified by:
      setIdentifier in interface NodeWithIdentifier<Name>
    • asString

      public String asString()
      Returns:
      the complete qualified name. Only the identifiers and the dots, so no comments or whitespace.
    • getQualifier

      public Optional<Name> getQualifier()
    • setQualifier

      public Name setQualifier(Name qualifier)
    • remove

      public boolean remove(Node node)
      Overrides:
      remove in class Node
    • removeQualifier

      public Name removeQualifier()
    • clone

      public Name clone()
      Overrides:
      clone in class Node
    • getMetaModel

      public NameMetaModel getMetaModel()
      Overrides:
      getMetaModel in class Node
      Returns:
      get JavaParser specific node introspection information.
    • replace

      public boolean replace(Node node, Node replacementNode)
      Overrides:
      replace in class Node
    • isTopLevel

      public boolean isTopLevel()
      A top level name is a name that is not contained in a larger Name instance.
    • isInternal

      public boolean isInternal()
      An internal name is a name that constitutes a part of a larger Name instance.