Class VarType

All Implemented Interfaces:
NodeWithRange<Node>, NodeWithTokenRange<Node>, Observable, Visitable, HasParentNode<Node>, Resolvable<ResolvedType>, Cloneable

public class VarType extends Type

A type called "var" waiting for Java to infer it.

Examples:
  1. var a = 1;
  2. var a = new ArrayList<String>();
  • Constructor Details

    • VarType

      public VarType()
    • VarType

      public VarType(TokenRange tokenRange)
      This constructor is used by the parser and is considered private.
  • Method Details

    • setAnnotations

      public VarType setAnnotations(NodeList<AnnotationExpr> annotations)
      Overrides:
      setAnnotations in class Type
    • asString

      public String asString()
      Specified by:
      asString in class Type
    • clone

      public VarType clone()
      Overrides:
      clone in class Type
    • getMetaModel

      public VarTypeMetaModel getMetaModel()
      Overrides:
      getMetaModel in class Type
      Returns:
      get JavaParser specific node introspection information.
    • resolve

      public ResolvedType resolve()
      Specified by:
      resolve in interface Resolvable<ResolvedType>
      Specified by:
      resolve in class Type
    • accept

      public <R,​ A> R accept(GenericVisitor<R,​A> v, A arg)
      Description copied from interface: Visitable
      Accept method for visitor support.
      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.
      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)
    • isVarType

      public boolean isVarType()
      Overrides:
      isVarType in class Type
    • asVarType

      public VarType asVarType()
      Overrides:
      asVarType in class Type
    • toVarType

      public Optional<VarType> toVarType()
      Overrides:
      toVarType in class Type
    • ifVarType

      public void ifVarType(Consumer<VarType> action)
      Overrides:
      ifVarType in class Type