Package ch.njol.skript.lang.function
Class DynamicFunctionReference<Result>
java.lang.Object
ch.njol.skript.lang.function.DynamicFunctionReference<Result>
- Type Parameters:
Result- The return type of this function, if known.
- All Implemented Interfaces:
AnyNamed,AnyProvider,Contract,Executable<org.bukkit.event.Event,,Result[]> Validated
public class DynamicFunctionReference<Result>
extends Object
implements Contract, Executable<org.bukkit.event.Event,Result[]>, Validated, AnyNamed
A partial reference to a Skript function.
This reference knows some of its information in advance (such as the function's name)
but will not be resolved until it receives inputs for the first time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn index-linking key for a particular set of input expressions. -
Constructor Summary
ConstructorsConstructorDescriptionDynamicFunctionReference(Function<? extends Result> function) DynamicFunctionReference(@NotNull String name) DynamicFunctionReference(@NotNull String name, @Nullable Script source) -
Method Summary
Modifier and TypeMethodDescriptionResult @Nullable []@Nullable Class<?> getReturnType(Expression<?>... arguments) voidMark a thing as no longer safe to use.booleanisSingle(Expression<?>... arguments) @NotNull Stringname()static @Nullable DynamicFunctionReference<?> parseFunction(String name) Attempts to parse a function reference from the format it would be stringified in.static @Nullable DynamicFunctionReference<?> resolveFunction(String name, @Nullable Script script) Used to resolve a function from its name.@Nullable Scriptsource()toString()booleanvalid()Implementations ought to specify what 'valid' means locally (e.g.@Nullable Expression<?> validate(Expression<?>[] parameters) Validates whether dynamic inputs are appropriate for the resolved function.@Nullable Expression<?> Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.njol.skript.lang.util.common.AnyNamed
setName, supportsNameChange
-
Constructor Details
-
DynamicFunctionReference
-
DynamicFunctionReference
-
DynamicFunctionReference
-
-
Method Details
-
source
-
name
-
isSingle
-
getReturnType
- Specified by:
getReturnTypein interfaceContract- Returns:
- What this will return, given these parameters
- See Also:
-
execute
- Specified by:
executein interfaceExecutable<org.bukkit.event.Event,Result[]>
-
invalidate
public void invalidate()Description copied from interface:ValidatedMark a thing as no longer safe to use. This should (typically) not be used by external modifiers, but implementations may differ.
Implementations that do not want to expose an invalidator hook may throw anUnsupportedOperationException, which is protected by the internal contract.- Specified by:
invalidatein interfaceValidated
-
valid
public boolean valid()Description copied from interface:ValidatedImplementations ought to specify what 'valid' means locally (e.g. should a new copy be obtained?) when overriding this method. -
toString
-
validate
Validates whether dynamic inputs are appropriate for the resolved function. If the inputs are acceptable, this will collect them into an expression list (the output of which can be passed directly to the task).- Parameters:
parameters- The input types to check- Returns:
- A combined expression list, if these inputs are appropriate for the function
-
validate
-
parseFunction
Attempts to parse a function reference from the format it would be stringified in. The name can include the source script name for the case of parsing local functions.- Parameters:
name- The function name, possibly including its script name- Returns:
- A reference, if one is available
-
resolveFunction
@Nullable public static @Nullable DynamicFunctionReference<?> resolveFunction(String name, @Nullable @Nullable Script script) Used to resolve a function from its name.- Parameters:
name- The function namescript- Potentially, the script it is from, if one is known- Returns:
- A function reference, if one is available.
-