Class VariableValueParameters
- java.lang.Object
-
- org.spongepowered.api.command.parameter.managed.standard.VariableValueParameters
-
public final class VariableValueParameters extends java.lang.Object
Builders and factory for parameters that require configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
VariableValueParameters.DynamicChoicesBuilder<T>
A builder that creates aValueParameter
that tries to match an argument against a dynamic set of choices and returns an appropriate object based on the supplied argument.static interface
VariableValueParameters.Factory
A factory that createsValueParameter
s or their builders.static interface
VariableValueParameters.LiteralBuilder<T>
A builder that createsValueParameter
s that requires a specific sequence of arguments.static interface
VariableValueParameters.NumberRangeBuilder<T extends java.lang.Number>
A builder that creates a parameter that can parse a boundedNumber
.static interface
VariableValueParameters.RegistryEntryBuilder<T>
A builder that creates aValueParameter
that attempts to get a specificregistry
entry by the supplied ID.static interface
VariableValueParameters.StaticChoicesBuilder<T>
A builder that creates aValueParameter
that tries to match an argument against a fixed set of choices and returns an appropriate object based on the supplied argument.static interface
VariableValueParameters.TextBuilder
A builder that creates a parameter that serializes strings intoComponent
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static VariableValueParameters.NumberRangeBuilder<java.lang.Double>
doubleRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded doubleValueParameter
.static <T> VariableValueParameters.DynamicChoicesBuilder<T>
dynamicChoicesBuilder(java.lang.Class<T> returnType)
Creates a builder that can build aValueParameter
that tries to match an argument against a dynamic list of choices.static <T extends java.lang.Enum<T>>
ValueParameter<T>enumChoices(java.lang.Class<T> enumClass)
Creates aValueParameter
that tries to match an argument with a value from a specified enum case-insensitively.static VariableValueParameters.NumberRangeBuilder<java.lang.Float>
floatRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded floatValueParameter
.static VariableValueParameters.NumberRangeBuilder<java.lang.Integer>
integerRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded integerValueParameter
.static <T> VariableValueParameters.LiteralBuilder<T>
literalBuilder(java.lang.Class<T> returnType)
Creates a builder that builds aValueParameter
that tries to match an a series of arguments with a supplied literal.static VariableValueParameters.NumberRangeBuilder<java.lang.Long>
longRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded longValueParameter
.static <T> VariableValueParameters.RegistryEntryBuilder<T>
registryEntryBuilder(java.util.function.Function<CommandContext,@Nullable RegistryHolder> holderProvider, RegistryType<T> registryKey)
Creates a builder that can build aValueParameter
that returns an appropriateregistry
entry from an argument.static <T> VariableValueParameters.RegistryEntryBuilder<T>
registryEntryBuilder(java.util.List<java.util.function.Function<CommandContext,@Nullable RegistryHolder>> holderProviders, RegistryType<T> registryKey)
Creates a builder that can build aValueParameter
that returns an appropriateregistry
entry from an argument.static <T> VariableValueParameters.RegistryEntryBuilder<T>
registryEntryBuilder(DefaultedRegistryType<T> type)
Creates a builder that can build aValueParameter
that returns an appropriate type from the providedRegistry
from an argument.static <T> VariableValueParameters.StaticChoicesBuilder<T>
staticChoicesBuilder(java.lang.Class<T> returnType)
Creates a builder that can build aValueParameter
that tries to match an argument against a fixed list of choices.static VariableValueParameters.TextBuilder
textBuilder()
Creates a builder that builds aValueParameter
that tries to construct aComponent
from an argument.static ValueParameter<java.lang.String>
validatedString(java.util.regex.Pattern pattern)
Creates aValueParameter
that validates the input.
-
-
-
Method Detail
-
registryEntryBuilder
public static <T> VariableValueParameters.RegistryEntryBuilder<T> registryEntryBuilder(java.util.function.Function<CommandContext,@Nullable RegistryHolder> holderProvider, RegistryType<T> registryKey)
Creates a builder that can build aValueParameter
that returns an appropriateregistry
entry from an argument.- Type Parameters:
T
- The type in theRegistry
- Parameters:
holderProvider
- The provider for aRegistryHolder
to retrieve the selectedRegistry
fromregistryKey
- TheRegistryKey
that represents the targetRegistry
to get objects from- Returns:
- The builder
-
registryEntryBuilder
public static <T> VariableValueParameters.RegistryEntryBuilder<T> registryEntryBuilder(java.util.List<java.util.function.Function<CommandContext,@Nullable RegistryHolder>> holderProviders, RegistryType<T> registryKey)
Creates a builder that can build aValueParameter
that returns an appropriateregistry
entry from an argument.- Type Parameters:
T
- The type in theRegistry
- Parameters:
holderProviders
- The providers forRegistryHolder
s to retrieve the selectedRegistry
fromregistryKey
- TheRegistryKey
that represents the targetRegistry
to get objects from- Returns:
- The builder
-
registryEntryBuilder
public static <T> VariableValueParameters.RegistryEntryBuilder<T> registryEntryBuilder(DefaultedRegistryType<T> type)
Creates a builder that can build aValueParameter
that returns an appropriate type from the providedRegistry
from an argument.- Type Parameters:
T
- The type in theRegistry
- Parameters:
type
- TheDefaultedRegistryType
to use to retrieve aRegistry
that contains the objects to retrieve- Returns:
- The builder
-
staticChoicesBuilder
public static <T> VariableValueParameters.StaticChoicesBuilder<T> staticChoicesBuilder(java.lang.Class<T> returnType)
Creates a builder that can build aValueParameter
that tries to match an argument against a fixed list of choices.If the list of choices changes during the lifetime of the server, use
dynamicChoicesBuilder(Class)
instead.- Type Parameters:
T
- The type that will be returned- Parameters:
returnType
- The type of object that the resultingValueParameter
will return.- Returns:
- The builder
-
dynamicChoicesBuilder
public static <T> VariableValueParameters.DynamicChoicesBuilder<T> dynamicChoicesBuilder(java.lang.Class<T> returnType)
Creates a builder that can build aValueParameter
that tries to match an argument against a dynamic list of choices.If the list of choices does not change during the lifetime of the server, use
staticChoicesBuilder(Class)
instead.- Type Parameters:
T
- The type that will be returned- Parameters:
returnType
- The type of object that the resultingValueParameter
will return.- Returns:
- The builder
-
literalBuilder
public static <T> VariableValueParameters.LiteralBuilder<T> literalBuilder(java.lang.Class<T> returnType)
Creates a builder that builds aValueParameter
that tries to match an a series of arguments with a supplied literal.- Type Parameters:
T
- The type that will be returned- Parameters:
returnType
- The type of object that the resultingValueParameter
will return.- Returns:
- The builder
-
textBuilder
public static VariableValueParameters.TextBuilder textBuilder()
Creates a builder that builds aValueParameter
that tries to construct aComponent
from an argument.- Returns:
- The new builder
-
enumChoices
public static <T extends java.lang.Enum<T>> ValueParameter<T> enumChoices(java.lang.Class<T> enumClass)
Creates aValueParameter
that tries to match an argument with a value from a specified enum case-insensitively.- Type Parameters:
T
- TheEnum
class type- Parameters:
enumClass
- TheEnum
class type that this will represent- Returns:
- The appropriate
ValueParameter
-
doubleRange
public static VariableValueParameters.NumberRangeBuilder<java.lang.Double> doubleRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded doubleValueParameter
.- Returns:
- The
VariableValueParameters.NumberRangeBuilder
-
floatRange
public static VariableValueParameters.NumberRangeBuilder<java.lang.Float> floatRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded floatValueParameter
.- Returns:
- The
VariableValueParameters.NumberRangeBuilder
-
integerRange
public static VariableValueParameters.NumberRangeBuilder<java.lang.Integer> integerRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded integerValueParameter
.- Returns:
- The
VariableValueParameters.NumberRangeBuilder
-
longRange
public static VariableValueParameters.NumberRangeBuilder<java.lang.Long> longRange()
Creates aVariableValueParameters.NumberRangeBuilder
that creates a bounded longValueParameter
.- Returns:
- The
VariableValueParameters.NumberRangeBuilder
-
validatedString
public static ValueParameter<java.lang.String> validatedString(java.util.regex.Pattern pattern)
Creates aValueParameter
that validates the input.- Parameters:
pattern
- ThePattern
used to validate the string- Returns:
- The
ValueParameter
-
-