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.
  • Method Details

    • name

      @NotNull @NotNull String name()
      Returns:
      The name of this parameter.
    • type

      @NotNull @NotNull Class<T> type()
      Returns:
      The type of this parameter.
    • modifiers

      @NotNull @Unmodifiable @NotNull Set<Parameter.Modifier> modifiers()
      Returns:
      All modifiers belonging to this parameter.
    • hasModifier

      default boolean hasModifier(Parameter.Modifier modifier)
      Returns whether this parameter has the specified modifier.
      Parameters:
      modifier - The modifier.
      Returns:
      True when modifiers() contains the specified modifier, false if not.
    • getModifier

      default <M extends Parameter.Modifier> M getModifier(Class<M> modifierClass)
      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.KEYED modifier, the returned array will contain KeyedValue objects, 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; or null to use the default value if present
      event - 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 is null and this parameter does not have a default value
    • isSingle

      default boolean isSingle()
      Returns:
      Whether this parameter is for single values.
    • single

      @Deprecated(forRemoval=true, since="2.14") default boolean single()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use isSingle() instead.
    • toFormattedString

      default String toFormattedString()
      Returns:
      A human-readable string representing this parameter.