Class ConvertedLiteral<F,T>
- All Implemented Interfaces:
Debuggable
,Expression<T>
,Literal<T>
,SyntaxElement
- See Also:
SimpleLiteral
-
Field Summary
Fields inherited from class ch.njol.skript.lang.util.ConvertedExpression
source, to
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks this expression against the given checker.boolean
Checks this expression against the given checker.T[]
getAll()
T[]
getArray()
T[]
getArray(org.bukkit.event.Event e)
Get all the values of this expression.<R> @Nullable Literal<? extends R>
getConvertedExpression(Class<R>... to)
Tries to convert this expression to the given type.getSingle(org.bukkit.event.Event e)
Get the single value of this expression.iterator(org.bukkit.event.Event e)
Returns the same asExpression.getArray(Event)
but as an iterator.toString(@Nullable org.bukkit.event.Event e, boolean debug)
Methods inherited from class ch.njol.skript.lang.util.ConvertedExpression
acceptChange, beforeChange, change, getAll, getAnd, getReturnType, getSource, getTime, init, isDefault, isLoopOf, isSingle, newInstance, setTime, simplify, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.Debuggable
toString
Methods inherited from interface ch.njol.skript.lang.Expression
acceptChange, beforeChange, change, getAll, getAnd, getReturnType, getSource, getTime, isDefault, isLoopOf, isSingle, setTime, simplify, stream
Methods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser, init
-
Field Details
-
data
-
-
Constructor Details
-
ConvertedLiteral
-
-
Method Details
-
getConvertedExpression
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 interfaceExpression<F>
- Specified by:
getConvertedExpression
in interfaceLiteral<F>
- Overrides:
getConvertedExpression
in classConvertedExpression<F,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
-
toString
- Specified by:
toString
in interfaceDebuggable
- Overrides:
toString
in classConvertedExpression<F,T>
- Parameters:
e
- The event to get information to. This is always null if debug == false.debug
- If true this should print more information, if false this should print what is shown to the end user- Returns:
- String representation of this object
-
getArray
-
getAll
-
getArray
Description copied from interface:Expression
Get all the values of this expression. The returned array is empty if this expression doesn't have any values for the given event.The returned array must not contain any null values.
Do not use this in conditions, use
Expression.check(Event, Checker, boolean)
instead.- Specified by:
getArray
in interfaceExpression<F>
- Overrides:
getArray
in classConvertedExpression<F,T>
- Parameters:
e
- The event- Returns:
- An array of values of this expression which must neither be null nor contain nulls, and which must not be an internal array.
-
getSingle
-
getSingle
Description copied from interface:Expression
Get the single value of this expression.This method may only return null if it always returns null for the given event, i.e. it is equivalent to getting a random element out of
Expression.getAll(Event)
or null iff that array is empty.Do not use this in conditions, use
Expression.check(Event, Checker, boolean)
instead.- Specified by:
getSingle
in interfaceExpression<F>
- Overrides:
getSingle
in classConvertedExpression<F,T>
- Parameters:
e
- The event- Returns:
- The value or null if this expression doesn't have any value for the event
-
iterator
Description copied from interface:Expression
Returns the same asExpression.getArray(Event)
but as an iterator. This method should be overriden by expressions intended to be looped to increase performance.- Specified by:
iterator
in interfaceExpression<F>
- Overrides:
iterator
in classConvertedExpression<F,T>
- Parameters:
e
- The event- Returns:
- An iterator to iterate over all values of this expression which may be empty and/or null, but must not return null elements.
-
check
Description copied from interface:Expression
Checks this expression against the given checker. This method must only be used around other checks, useExpression.check(Event, Checker, boolean)
for a simple ckeck or the innermost check of a nested check.- Specified by:
check
in interfaceExpression<F>
- Overrides:
check
in classConvertedExpression<F,T>
- Parameters:
e
- The eventc
- A checker- Returns:
- Whether this expression matches the given checker
- See Also:
SimpleExpression.check(Object[], Checker, boolean, boolean)
-
check
Description copied from interface:Expression
Checks this expression against the given checker. This is the normal version of this method and the one which must be used for simple checks, or as the innermost check of nested checks.Usual implementation (may differ, e.g. may return false for nonexistent values independent of negated):
return negated ^
Expression.check(Event, Checker)
;- Specified by:
check
in interfaceExpression<F>
- Overrides:
check
in classConvertedExpression<F,T>
- Parameters:
e
- The eventc
- A checkernegated
- The checking condition's negated state. This is used to invert the output of the checker if set to true (i.e. negated ^ checker.check(...))- Returns:
- Whether this expression matches or doesn't match the given checker depending on the condition's negated state.
- See Also:
SimpleExpression.check(Object[], Checker, boolean, boolean)
-