Interface Expression<T>
- Type Parameters:
T- the type of value this expression returns
- All Superinterfaces:
SyntaxElement
- All Known Subinterfaces:
Literal<T>
- All Known Implementing Classes:
CondExprCompare, CondExprContains, CondExprDateCompare, CondExprIsDivisible, CondExprIsEmpty, CondExprIsPrime, CondExprIsSet, CondExprMatch, CondExprStartsEnds, ConditionalExpression, ContextExpression, ConvertedExpression, ExecExprListOperators, ExecExprReplace, ExecutableExpression, ExprAmount, ExprAnswer, ExprArithmeticOperators, ExprBinaryMathFunctions, ExprBooleanOperators, ExprColorFromHex, ExprColorFromRGB, ExprColorValues, ExprDateAgoLater, ExprDateFormatted, ExprDateFromUnix, ExprDateInformation, ExprDateNow, ExprDateTimestamp, ExprDateTodayAt, ExprDefaultValue, ExprDifference, ExprDurationSinceUntil, ExprElement, ExpressionList, ExprFunctionCall, ExprLength, ExprLoopValue, ExprMutableList, ExprNumberConvertBase, ExprParseAs, ExprRandomNumber, ExprRange, ExprSingleParameter, ExprStringCase, ExprStringCharAt, ExprStringChars, ExprStringOccurrence, ExprStringSplitJoin, ExprSubstring, ExprTernary, ExprUnaryMathFunctions, ExprVariableIndices, ExprWhether, LiteralList, LitFunctionParameter, LitScriptName, LitTimeConstants, PropertyConditional, PropertyExpression, RestrictedExpression, SectionValue, SimpleExpression, SimpleLiteral, TaggedExpression, Variable, VariableString
An expression, i.e a
SyntaxElement representing a value with some type.-
Method Summary
Modifier and TypeMethodDescriptionacceptsChange(ChangeMode mode) Determines whether this expression can be changed according to a specificChangeMode, and what type of values it can be changed with.default booleanacceptsChange(ChangeMode mode, Expression<?> changeWith) Determines whether this expression can be changed to a specificChangeModeand type class.default booleanacceptsChange(ChangeMode mode, Class<?> needle, boolean isSingle) Determines whether this expression can be changed to a specificChangeModeand type class.default voidchange(TriggerContext ctx, ChangeMode changeMode, Object[] changeWith) Changes this expression with the given values according to the given modedefault booleancheck(TriggerContext ctx, Predicate<? super T> predicate) Checks this expression against the givenPredicatedefault booleancheck(TriggerContext ctx, Predicate<? super T> predicate, boolean negated) Checks this expression against the givenPredicatestatic <T> booleanChecks an array of elements against a given predicatedefault <C> Optional<? extends Expression<C>> convertExpression(Class<C> to) Converts this expression from it's current type (T) to another type, using converters.default T[]getArray(TriggerContext ctx) Retrieves all values of this Expressions, without accounting for possible modifiers.static <S extends CodeSection>
Optional<? extends S> getLinkedSection(ParserState parserState, Class<? extends S> sectionClass) static <S extends CodeSection>
Optional<? extends S> getLinkedSection(ParserState parserState, Class<? extends S> sectionClass, Function<? super List<? extends S>, Optional<? extends S>> selector) static <S extends CodeSection>
List<? extends S> getMatchingSections(ParserState parserState, Class<? extends S> sectionClass) getSingle(TriggerContext ctx) Gets a single value out of this Expressiondefault Expression<?> T[]getValues(TriggerContext ctx) Retrieves all values of this Expression, accounting for possible modifiers.default booleandefault booleanWhen this expression is looped, returns what the loop reference (as in loop-<reference>) should be in order to describe each element of the values of this expression.default booleanisSingle()iterator(TriggerContext ctx) default voidsetAndList(boolean isAndList) stream(TriggerContext ctx) Methods inherited from interface SyntaxElement
init, toString
-
Method Details
-
getValues
Retrieves all values of this Expression, accounting for possible modifiers. This means that if this is an or-list, it will choose a random value to return.- Parameters:
ctx- the event- Returns:
- an array of the values
- See Also:
-
getArray
Retrieves all values of this Expressions, without accounting for possible modifiers. This means that if this is an or-list, it will still return all possible values.- Parameters:
ctx- the event- Returns:
- an array of the raw values
-
getSingle
Gets a single value out of this Expression- Parameters:
ctx- the event- Returns:
- the single value of this Expression, or empty if it has no value
- Throws:
SkriptRuntimeException- if the expression returns more than one value
-
isSingle
default boolean isSingle()- Returns:
- whether this expression returns a single value. By default, this is defined on registration, but it can be overridden.
-
getReturnType
- Returns:
- the return type of this expression. By default, this is defined on registration, but, like isSingle(), can be overriden.
-
acceptsChange
Determines whether this expression can be changed according to a specificChangeMode, and what type of values it can be changed with.- Parameters:
mode- the mode this Expression would be changed with- Returns:
- an array of classes describing what types this Expression can be changed with, empty if it
shouldn't be changed with the given change mode. If the change mode is
ChangeMode.DELETEorChangeMode.RESET, then an empty array should be returned.
-
acceptsChange
Determines whether this expression can be changed to a specificChangeModeand type class.- Parameters:
mode- the mode this Expression would be changed withchangeWith- the Expression you want to change with- Returns:
- whether or not this Expression should be changed with the given change mode and class.
-
acceptsChange
Determines whether this expression can be changed to a specificChangeModeand type class.- Parameters:
mode- the mode this Expression would be changed withneedle- the type class of the instance this Expression would be changed withisSingle- whether or not the instance this Expression would be changed with is single- Returns:
- whether or not this Expression should be changed with the given change mode and class.
-
change
Changes this expression with the given values according to the given mode- Parameters:
ctx- the eventchangeMode- the mode of changechangeWith- the values to change this Expression with
-
iterator
- Parameters:
ctx- the event- Returns:
- an iterator of the values of this expression
-
stream
- Parameters:
ctx- the event- Returns:
- a stream of the values of this expression
-
convertExpression
Converts this expression from it's current type (T) to another type, using converters.- Type Parameters:
C- the type to convert this Expression to- Parameters:
to- the class of the type to convert this Expression to- Returns:
- a converted Expression, or
nullif it couldn't be converted
-
isLoopOf
When this expression is looped, returns what the loop reference (as in loop-<reference>) should be in order to describe each element of the values of this expression.- Parameters:
s- the loop reference- Returns:
- whether the given reference describes this expression's elements. By default, returns
trueif the parameter is"value" - See Also:
-
isAndList
default boolean isAndList() -
setAndList
default void setAndList(boolean isAndList) -
getSource
-
check
Checks this expression against the givenPredicate- Parameters:
ctx- the eventpredicate- the predicate- Returns:
- whether the expression matches the predicate
-
check
Checks this expression against the givenPredicate- Parameters:
ctx- the eventpredicate- the predicatenegated- whether the result should be inverted- Returns:
- whether the expression matches the predicate
-
check
Checks an array of elements against a given predicate- Type Parameters:
T- the type of the elements to check- Parameters:
all- the array to checkpredicate- the predicatenegated- whether the result should be invertedand- whether all elements of the array should match the predicate, or only one- Returns:
- whether the elements match the given predicate
-
getMatchingSections
static <S extends CodeSection> List<? extends S> getMatchingSections(ParserState parserState, Class<? extends S> sectionClass) -
getLinkedSection
static <S extends CodeSection> Optional<? extends S> getLinkedSection(ParserState parserState, Class<? extends S> sectionClass) -
getLinkedSection
static <S extends CodeSection> Optional<? extends S> getLinkedSection(ParserState parserState, Class<? extends S> sectionClass, Function<? super List<? extends S>, Optional<? extends S>> selector)
-