Interface Parameter<T>
- Type Parameters:
T- The type of the function parameter.
- All Known Implementing Classes:
Parameter,ScriptParameter
@NonExtendable
public interface Parameter<T>
Represents a function parameter.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a modifier that can be applied to a parameter when constructing one usingDefaultFunction.Builder.parameter(String, Class, Modifier[]). -
Method Summary
Modifier and TypeMethodDescriptiondefault Object[]evaluate(@Nullable Expression<? extends T> argument, org.bukkit.event.Event event) Evaluates the provided argument expression and returns the resulting values, taking into account this parameter's modifiers.default <M extends Parameter.Modifier>
MgetModifier(Class<M> modifierClass) Gets a modifier of the specified type if present.default booleanhasModifier(Parameter.Modifier modifier) Returns whether this parameter has the specified modifier.default booleanisSingle()@Unmodifiable @NotNull Set<Parameter.Modifier> @NotNull Stringname()default booleansingle()Deprecated, for removal: This API element is subject to removal in a future version.default Stringtype()
-
Method Details
-
name
- Returns:
- The name of this parameter.
-
type
- Returns:
- The type of this parameter.
-
modifiers
- Returns:
- All modifiers belonging to this parameter.
-
hasModifier
Returns whether this parameter has the specified modifier.- Parameters:
modifier- The modifier.- Returns:
- True when
modifiers()contains the specified modifier, false if not.
-
getModifier
Gets a modifier of the specified type if present.- Parameters:
modifierClass- The class of the modifier to retrieve- Returns:
- The modifier instance, or null if not present
-
evaluate
default Object[] evaluate(@Nullable @Nullable Expression<? extends T> argument, org.bukkit.event.Event event) Evaluates the provided argument expression and returns the resulting values, taking into account this parameter's modifiers.If this parameter has the
Parameter.Modifier.KEYEDmodifier, the returned array will containKeyedValueobjects, pairing each value with its corresponding key. If the argument expression does not provide keys, numerical indices (1, 2, 3, ...) will be used as keys; otherwise, the returned array will contain only the values.- Parameters:
argument- the argument passed to this parameter; ornullto use the default value if presentevent- the event in which to evaluate the expression- Returns:
- an object array containing either value-only elements or
KeyedValue[]when keyed - Throws:
IllegalStateException- if the argument isnulland this parameter does not have a default value
-
isSingle
default boolean isSingle()- Returns:
- Whether this parameter is for single values.
-
single
Deprecated, for removal: This API element is subject to removal in a future version.UseisSingle()instead. -
toFormattedString
- Returns:
- A human-readable string representing this parameter.
-
isSingle()instead.