Class LiteralList<T>

java.lang.Object
ch.njol.skript.lang.ExpressionList<T>
ch.njol.skript.lang.LiteralList<T>
All Implemented Interfaces:
Debuggable, Expression<T>, Literal<T>, Loopable<T>, Simplifiable<Expression<? extends T>>, SyntaxElement

public class LiteralList<T> extends ExpressionList<T> implements Literal<T>
A list of literals. Can contain UnparsedLiterals.
  • Constructor Details

    • LiteralList

      public LiteralList(Literal<? extends T>[] literals, Class<T> returnType, boolean and)
    • LiteralList

      public LiteralList(Literal<? extends T>[] literals, Class<T> returnType, Class<?>[] possibleReturnTypes, boolean and)
    • LiteralList

      public LiteralList(Literal<? extends T>[] literals, Class<T> returnType, boolean and, LiteralList<?> source)
    • LiteralList

      public LiteralList(Literal<? extends T>[] literals, Class<T> returnType, Class<?>[] possibleReturnTypes, boolean and, LiteralList<?> source)
  • Method Details

    • getArray

      public T[] getArray()
      Specified by:
      getArray in interface Literal<T>
    • getSingle

      public T getSingle()
      Specified by:
      getSingle in interface Literal<T>
    • getAll

      public T[] getAll()
      Specified by:
      getAll in interface Literal<T>
    • getConvertedExpression

      @Nullable public <R> @Nullable Literal<? extends R> getConvertedExpression(Class<R>... to)
      Description copied from interface: Expression
      Tries to convert this expression to the given type. This method can print an error prior to returning null to specify the cause.

      Please note that expressions whose returnType is not Object will not be parsed at all for a certain class if there's no converter from the expression's returnType to the desired class. Thus this method should only be overridden if this expression's returnType is Object.

      The returned expression should delegate this method to the original expression's method to prevent excessive converted expression chains (see also ConvertedExpression).

      Specified by:
      getConvertedExpression in interface Expression<T>
      Specified by:
      getConvertedExpression in interface Literal<T>
      Overrides:
      getConvertedExpression in class ExpressionList<T>
      Parameters:
      to - The desired return type of the returned expression
      Returns:
      Expression with the desired return type or null if the expression can't be converted to the given type. Returns the expression itself if it already returns the desired type.
      See Also:
    • getExpressions

      public Literal<? extends T>[] getExpressions()
      Overrides:
      getExpressions in class ExpressionList<T>
      Returns:
      The internal list of expressions. Can be modified with care.
    • simplify

      public Expression<T> simplify()
      Description copied from interface: Simplifiable
      Simplifies this object. This should be called immediately after init() returns true. If simplification is not possible, the object is returned as is.
      References to the original object should be replaced with the simplified object.
      Any returned object should attempt to maintain the original value of Debuggable.toString(Event, boolean). An addition indicating that the value was simplified can be added in the debug string. See SimplifiedLiteral for an example.
      Simplification should never invalidate contracts. For example, any simplified expression should take care to return the same or a more specific type than the original expression, never a more generic type. Likewise, be sure to maintain the behavior of change() and acceptsChange(). Failure to do so can result in unexpected behavior and tricky bugs.
      Finally, simplified results should update Expression.getSource() to point to the expression prior to simplification. This makes maintaining the above contracts easier.
      Specified by:
      simplify in interface Simplifiable<T>
      Overrides:
      simplify in class ExpressionList<T>
      Returns:
      the simplified object.
      See Also: