Class PropertyConditional<P>

java.lang.Object
io.github.syst3ms.skriptparser.lang.base.ConditionalExpression
io.github.syst3ms.skriptparser.lang.properties.PropertyConditional<P>
Type Parameters:
P - the type of the performer in this condition
All Implemented Interfaces:
Expression<Boolean>, SyntaxElement
Direct Known Subclasses:
CondExprIsDivisible, CondExprIsPrime, CondExprIsSet

public abstract class PropertyConditional<P> extends ConditionalExpression
This class can be used for an easier writing of conditions that contain only one type in the pattern and are in one of the following forms:
  • something is something
  • something can something
  • something has something
The plural and negated forms are also supported. The gains of using this class:
  • There is a useful toString() method and it works well with the plural and negated forms. It is implemented by default.
  • Registration is very straightforward.
  • The performer expression is automatically checked for nullity.
  • Field Details

  • Constructor Details

    • PropertyConditional

      public PropertyConditional()
  • Method Details

    • init

      public boolean init(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext)
      This default init() implementation automatically properly sets the performer in this condition, which can be accessed using getPerformer(). If this implementation is overridden for one reason or another, it must call setPerformer(Expression) properly.
      Parameters:
      expressions - an array of expressions representing all the expressions that are being passed to this syntax element.
      matchedPattern - the index of the pattern that was successfully matched. It corresponds to the order of the syntaxes in registration
      parseContext - an object containing additional information about the parsing of this syntax element, like regex matches and parse marks
      Returns:
      whether the initialization was successful or not.
      See Also:
    • check

      public boolean check(TriggerContext ctx)
      Specified by:
      check in class ConditionalExpression
    • check

      public boolean check(P performer)
      Tests this condition for each individual performer. Negated conditions are taken care of automatically, so one must not account for it in here.
      Parameters:
      performer - the performer
      Returns:
      whether the conditions is true for this performer
    • toString

      public String toString(TriggerContext ctx, boolean debug)
      Parameters:
      ctx - the event
      debug - whether to show additional information or not
      Returns:
      a String that should aim to resemble what is written in the script as closely as possible
    • toString

      protected String toString(TriggerContext ctx, boolean debug, String property)
    • getPerformer

      public Expression<P> getPerformer()
    • setPerformer

      public void setPerformer(Expression<P> performer)
    • composePatterns

      public static String[] composePatterns(String performer, ConditionalType conditionalType, String property)