Class AnnotationValue

  • All Implemented Interfaces:
    ASTNode

    public final class AnnotationValue
    extends Object
    implements ASTNode
    A single element-value pair inside an annotation use.
    • Constructor Detail

      • AnnotationValue

        public AnnotationValue​(String name,
                               Expression value,
                               SourceLocation location)
        Creates an element-value pair, adopting the value expression.
        Parameters:
        name - the element name
        value - the element value
        location - the source location, or null for unknown
      • AnnotationValue

        public AnnotationValue​(String name,
                               Expression value)
        Creates an element-value pair at an unknown location.
        Parameters:
        name - the element name
        value - the element value
    • Method Detail

      • getName

        public String getName()
        Returns:
        the name
      • setName

        public void setName​(String name)
        Sets the element name.
        Parameters:
        name - the element name
      • getValue

        public Expression getValue()
        Returns:
        the value
      • setValue

        public void setValue​(Expression value)
        Sets the element value.
        Parameters:
        value - the element value
      • getLocation

        public SourceLocation getLocation()
        Description copied from interface: ASTNode
        Gets the source location of this node.
        Specified by:
        getLocation in interface ASTNode
        Returns:
        the location
      • getParent

        public ASTNode getParent()
        Description copied from interface: ASTNode
        Gets the parent node in the AST tree.
        Specified by:
        getParent in interface ASTNode
        Returns:
        the parent
      • setParent

        public void setParent​(ASTNode parent)
        Sets the parent node.
        Specified by:
        setParent in interface ASTNode
        Parameters:
        parent - the new parent
      • withName

        public AnnotationValue withName​(String name)
        Sets the element name.
        Parameters:
        name - the element name
        Returns:
        this pair
      • withValue

        public AnnotationValue withValue​(Expression value)
        Replaces the element value, adopting the new expression and releasing the old one.
        Parameters:
        value - the element value
        Returns:
        this pair
      • getChildren

        public List<ASTNode> getChildren()
        Description copied from interface: ASTNode
        Lists the direct children a node holds, in source order.
        Specified by:
        getChildren in interface ASTNode
        Returns:
        the direct children, empty for a leaf
      • accept

        public <T> T accept​(SourceVisitor<T> visitor)
        Description copied from interface: ASTNode
        Accepts a visitor for this node.
        Specified by:
        accept in interface ASTNode
        Type Parameters:
        T - the return type of the visitor
        Parameters:
        visitor - the visitor to accept
        Returns:
        the result from the visitor