Class SynchronizedStmt

  • All Implemented Interfaces:
    ASTNode, Statement

    public final class SynchronizedStmt
    extends Object
    implements Statement
    A synchronized block guarding its body with a lock expression.
    • Constructor Detail

      • SynchronizedStmt

        public SynchronizedStmt​(Expression lock,
                                Statement body,
                                SourceLocation location)
        Creates a synchronized block and parents the lock and body to it.
        Parameters:
        lock - the monitor expression
        body - the guarded body
        location - source location, or null for unknown
        Throws:
        NullPointerException - if lock or body is null
      • SynchronizedStmt

        public SynchronizedStmt​(Expression lock,
                                Statement body)
        Creates a synchronized block with an unknown location.
        Parameters:
        lock - the monitor expression
        body - the guarded body
        Throws:
        NullPointerException - if lock or body is null
    • Method Detail

      • getLock

        public Expression getLock()
        Returns:
        the lock
      • setLock

        public void setLock​(Expression lock)
        Replaces the monitor expression, reparenting old and new nodes.
        Parameters:
        lock - the new monitor expression
      • getBody

        public Statement getBody()
        Returns:
        the body
      • setBody

        public void setBody​(Statement body)
        Replaces the guarded body, reparenting old and new nodes.
        Parameters:
        body - the new body
      • getLocation

        public SourceLocation getLocation()
        Description copied from interface: ASTNode
        Gets the source location of this node.
        Specified by:
        getLocation in interface ASTNode
        Returns:
        the source location, or null if unknown
      • 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 enclosing AST node.
        Specified by:
        setParent in interface ASTNode
        Parameters:
        parent - the new parent node
      • withLock

        public SynchronizedStmt withLock​(Expression lock)
        Replaces the monitor expression, reparenting old and new nodes.
        Parameters:
        lock - the new monitor expression
        Returns:
        this statement
        Throws:
        NullPointerException - if lock is null
      • withBody

        public SynchronizedStmt withBody​(Statement body)
        Replaces the guarded body, reparenting old and new nodes.
        Parameters:
        body - the new body
        Returns:
        this statement
        Throws:
        NullPointerException - if body is null
      • 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