Klasse GuardedPattern


public class GuardedPattern extends Pattern
GuardedPattern pattern AST node type.
 GuardedPattern:
      Pattern when Expression
 
Seit:
3.27
  • Felddetails

    • PATTERN_PROPERTY

      public static final ChildPropertyDescriptor PATTERN_PROPERTY
      The "pattern" structural property of this node type (child type: Pattern). (added in JEP 406).
    • EXPRESSION_PROPERTY

      public static final ChildPropertyDescriptor EXPRESSION_PROPERTY
      The "expression" structural property of this node type (child type: Expression). (added in JEP 406).
  • Methodendetails

    • propertyDescriptors

      public static List propertyDescriptors(int apiLevel)
      Returns a list of structural property descriptors for this node type. Clients must not modify the result.
      Parameter:
      apiLevel - the API level; one of the AST.JLS* constants
      Gibt zurück:
      a list of property descriptors (element type: StructuralPropertyDescriptor)
    • propertyDescriptors

      public static List propertyDescriptors(int apiLevel, boolean previewEnabled)
      Returns a list of structural property descriptors for this node type. Clients must not modify the result.
      Parameter:
      apiLevel - the API level; one of the AST.JLS* constants
      previewEnabled - the previewEnabled flag
      Gibt zurück:
      a list of property descriptors (element type: StructuralPropertyDescriptor)
    • getExpression

      public Expression getExpression()
      Returns the conditional expression of this pattern, or null if there is none (the "default:" case).
      Gibt zurück:
      the expression node, or null if there is none
    • getPattern

      public Pattern getPattern()
      Returns the pattern of this Guarded Pattern, or empty if there is none.
      Gibt zurück:
      the pattern node (element type: Pattern)
      Löst aus:
      UnsupportedOperationException - if this operation is used other than JLS18
      UnsupportedOperationException - if this expression is used with previewEnabled flag as false
    • setExpression

      public void setExpression(Expression expression)
      Sets the conditional expression of this pattern, or clears it (turns it into the "default:" case).
      Parameter:
      expression - the expression node, or null to turn it into the "default:" case
      Löst aus:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
      • a cycle in would be created
    • setPattern

      public void setPattern(Pattern pattern)
      Sets the pattern of this switch case.
      Parameter:
      pattern -
      Löst aus:
      UnsupportedOperationException - if this operation is used not for JLS18
      UnsupportedOperationException - if this operation is used without previewEnabled
    • setRestrictedIdentifierStartPosition

      protected void setRestrictedIdentifierStartPosition(int restrictedIdentifierStartPosition)
      A character index into the original restricted identifier source string, or -1 if no restricted identifier source position information is available for this node; -1 by default.
    • getRestrictedIdentifierStartPosition

      public int getRestrictedIdentifierStartPosition()
      A character index into the original restricted identifier source string, or -1 if no restricted identifier source position information is available for this node; -1 by default.
      Seit:
      3.30