Class VariableDeclarator

    • Constructor Detail

      • VariableDeclarator

        public VariableDeclarator()
      • VariableDeclarator

        public VariableDeclarator​(Type type,
                                  String variableName)
      • VariableDeclarator

        public VariableDeclarator​(Type type,
                                  SimpleName name)
      • VariableDeclarator

        public VariableDeclarator​(Type type,
                                  String variableName,
                                  Expression initializer)
      • VariableDeclarator

        public VariableDeclarator​(Type type,
                                  SimpleName name,
                                  Expression initializer)
        Defines the declaration of a variable.
        Parameters:
        name - The identifier for this variable. IE. The variables name.
        initializer - What this variable should be initialized to. An AssignExpr is unnecessary as the = operator is already added.
      • VariableDeclarator

        @Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
        public VariableDeclarator​(TokenRange tokenRange,
                                  Type type,
                                  SimpleName name,
                                  Expression initializer)
        This constructor is used by the parser and is considered private.
    • Method Detail

      • customInitialization

        protected void customInitialization()
        Description copied from class: Node
        Called in every constructor for node specific code. It can't be written in the constructor itself because it will be overwritten during code generation.
        Overrides:
        customInitialization in class Node
      • 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)
      • setInitializer

        @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
        public VariableDeclarator setInitializer​(Expression initializer)
        Sets the initializer expression
        Parameters:
        initializer - the initializer expression, can be null
        Returns:
        this, the VariableDeclarator
      • setInitializer

        public VariableDeclarator setInitializer​(String init)
        Will create a NameExpr with the initializer param
        Parameters:
        init - the initializer expression, can be null
        Returns:
        this, the VariableDeclarator
      • remove

        @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
        public boolean remove​(Node node)
        Overrides:
        remove in class Node
      • removeInitializer

        @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
        public VariableDeclarator removeInitializer()
      • replace

        @Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
        public boolean replace​(Node node,
                               Node replacementNode)
        Overrides:
        replace in class Node