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>, 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, 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

      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:
      Converter, ConvertedExpression
    • 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: Expression
      Simplifies the expression, e.g. if it only contains literals the expression may be simplified to a literal, and wrapped expressions are unwrapped.

      After this method was used the toString methods are likely not useful anymore.

      This method is not yet used but will be used to improve efficiency in the future.

      Specified by:
      simplify in interface Expression<T>
      Overrides:
      simplify in class ExpressionList<T>
      Returns:
      A reference to a simpler version of this expression. Can change this expression directly and return itself if applicable, i.e. no references to the expression before this method call should be kept!