Class YieldStmt

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

public class YieldStmt extends Statement implements NodeWithExpression

The yield statement

Java 1.0-11

Does not exist.

Java 12

Yields an expression to be used in the switch-expression:
yield 123+456;
yield "more or less";
  • Constructor Details

    • YieldStmt

      public YieldStmt()
    • YieldStmt

      public YieldStmt(Expression expression)
    • YieldStmt

      public YieldStmt(TokenRange tokenRange, Expression expression)
      This constructor is used by the parser and is considered private.
  • Method Details

    • getExpression

      public Expression getExpression()
      Specified by:
      getExpression in interface NodeWithExpression
    • setExpression

      public YieldStmt setExpression(Expression expression)
      Sets the label
      Specified by:
      setExpression in interface NodeWithExpression
      Parameters:
      expression - the label or the expression, can be null
      Returns:
      this, the YieldStmt
    • 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)
    • isYieldStmt

      public boolean isYieldStmt()
      Overrides:
      isYieldStmt in class Statement
    • asYieldStmt

      public YieldStmt asYieldStmt()
      Overrides:
      asYieldStmt in class Statement
    • toYieldStmt

      public Optional<YieldStmt> toYieldStmt()
      Overrides:
      toYieldStmt in class Statement
    • ifYieldStmt

      public void ifYieldStmt(Consumer<YieldStmt> action)
      Overrides:
      ifYieldStmt in class Statement
    • replace

      public boolean replace(Node node, Node replacementNode)
      Overrides:
      replace in class Node
    • clone

      public YieldStmt clone()
      Overrides:
      clone in class Statement
    • getMetaModel

      public YieldStmtMetaModel getMetaModel()
      Overrides:
      getMetaModel in class Statement
      Returns:
      get JavaParser specific node introspection information.