Interface CtConditional<T>

All Superinterfaces:
Cloneable, CtCodeElement, CtElement, CtExpression<T>, CtQueryable, CtTypedElement<T>, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder, TemplateParameter<T>
All Known Implementing Classes:
CtConditionalImpl

public interface CtConditional<T> extends CtExpression<T>
This code element defines conditional expressions using the ? (ternary expressions). Example:
     System.out.println(
        1==0 ? "foo" : "bar" // <-- ternary conditional
     );
 
  • Method Details

    • getElseExpression

      CtExpression<T> getElseExpression()
      Gets the "false" expression.
    • getThenExpression

      CtExpression<T> getThenExpression()
      Gets the "true" expression.
    • getCondition

      CtExpression<Boolean> getCondition()
      Gets the condition expression.
    • setElseExpression

      <C extends CtConditional<T>> C setElseExpression(CtExpression<T> elseExpression)
      Sets the "false" expression.
    • setThenExpression

      <C extends CtConditional<T>> C setThenExpression(CtExpression<T> thenExpression)
      Sets the "true" expression.
    • setCondition

      <C extends CtConditional<T>> C setCondition(CtExpression<Boolean> condition)
      Sets the condition expression.
    • clone

      CtConditional<T> clone()
      Description copied from interface: CtElement
      Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methods Refactoring.copyType(CtType) and Refactoring.copyMethod(CtMethod) instead which does additional work beyond cloning.
      Specified by:
      clone in interface CtCodeElement
      Specified by:
      clone in interface CtElement
      Specified by:
      clone in interface CtExpression<T>
      Returns:
      a clone of this element. All children are cloned, but the parent of the returned clone is set to null.