Class InterfaceDecl

  • All Implemented Interfaces:
    ASTNode, TypeDecl

    public final class InterfaceDecl
    extends Object
    implements TypeDecl
    An interface declaration in the source AST, with its extended interfaces, type parameters, members, and nested types.
    • Constructor Detail

      • InterfaceDecl

        public InterfaceDecl​(String name,
                             SourceLocation location)
        Creates an interface with no modifiers or members.
        Parameters:
        name - the simple name
        location - the source position, or null for UNKNOWN
      • InterfaceDecl

        public InterfaceDecl​(String name)
        Creates an interface with no source position.
        Parameters:
        name - the simple name
    • Method Detail

      • setName

        public void setName​(String name)
        Renames the interface.
        Parameters:
        name - the new simple name
      • getExtendedInterfaces

        public NodeList<SourceType> getExtendedInterfaces()
        Returns:
        the extended interfaces
      • getTypeParameters

        public NodeList<SourceType> getTypeParameters()
        Returns:
        the type parameters
      • 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)
        Records the node this declaration hangs under.
        Specified by:
        setParent in interface ASTNode
        Parameters:
        parent - the enclosing node
      • withName

        public InterfaceDecl withName​(String name)
        Renames the interface.
        Parameters:
        name - the new simple name
        Returns:
        this declaration
      • withModifiers

        public InterfaceDecl withModifiers​(Set<Modifier> modifiers)
        Replaces the modifier set.
        Parameters:
        modifiers - the modifiers to hold
        Returns:
        this declaration
      • addModifier

        public InterfaceDecl addModifier​(Modifier modifier)
        Adds one modifier.
        Parameters:
        modifier - the modifier to add
        Returns:
        this declaration
      • addAnnotation

        public InterfaceDecl addAnnotation​(AnnotationExpr annotation)
        Appends an annotation.
        Parameters:
        annotation - the annotation to add
        Returns:
        this declaration
      • addExtendedInterface

        public InterfaceDecl addExtendedInterface​(SourceType iface)
        Appends a super-interface to the extends clause.
        Parameters:
        iface - the interface type to add
        Returns:
        this declaration
      • addTypeParameter

        public InterfaceDecl addTypeParameter​(SourceType typeParam)
        Appends a type parameter.
        Parameters:
        typeParam - the type parameter to add
        Returns:
        this declaration
      • addField

        public InterfaceDecl addField​(FieldDecl field)
        Appends a field.
        Parameters:
        field - the field to add
        Returns:
        this declaration
      • addMethod

        public InterfaceDecl addMethod​(MethodDecl method)
        Appends a method.
        Parameters:
        method - the method to add
        Returns:
        this declaration
      • addInnerType

        public InterfaceDecl addInnerType​(TypeDecl innerType)
        Appends a nested type.
        Parameters:
        innerType - the nested declaration to add
        Returns:
        this declaration
      • 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