Package me.keehl.elevators.api.models
Interface IElevatorActionVariable<T>
-
public interface IElevatorActionVariable<T>Describes a typed, aliased variable used to configure anIElevatorAction.Action variables are typically parsed from an action configuration string (e.g.
alias=value) and resolved at runtime to a strongly typed value.Defaults and invalid input
getDefaultObject()may benull.- Implementations may choose to return the default value when the input string is
nullor cannot be parsed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TgetDefaultObject()Returns the default value for this variable.@NotNull java.lang.StringgetMainAlias()Returns the primary alias used when serializing this variable (e.g.,"identifier").TgetObjectFromString(@Nullable java.lang.String value, @NotNull IElevatorAction action)Converts a configuration string into a typed variable value.@NotNull java.lang.StringgetStringFromObject(@NotNull java.lang.Object object)Converts a typed value into a string form suitable for serialization.booleanisGroupingAlias(@NotNull java.lang.String alias)Returns whether the provided alias matches this variable (case-insensitive).
-
-
-
Method Detail
-
getObjectFromString
@NotNull T getObjectFromString(@Nullable @Nullable java.lang.String value, @NotNull @NotNull IElevatorAction action)
Converts a configuration string into a typed variable value.Contract:
actionmust be non-null.valuemay benull; implementations may treatnullas "use default".- On parse failure, implementations may return
getDefaultObject().
- Parameters:
value- the raw string value to parse; may benullaction- the non-null action this variable belongs to (may be used for context/logging)- Returns:
- the parsed value, or the default value if
valueisnullor invalid
-
getStringFromObject
@NotNull @NotNull java.lang.String getStringFromObject(@NotNull @NotNull java.lang.Object object)Converts a typed value into a string form suitable for serialization.Contract:
objectmust be non-null.- Parameters:
object- the non-null value to serialize (typically of typeT)- Returns:
- the non-null string form of the value
- Throws:
java.lang.NullPointerException- ifobjectisnull
-
getMainAlias
@NotNull @NotNull java.lang.String getMainAlias()
Returns the primary alias used when serializing this variable (e.g.,"identifier").Contract: Never
null. Aliases are typically treated case-insensitively.- Returns:
- the non-null primary alias
-
getDefaultObject
@NotNull T getDefaultObject()
Returns the default value for this variable.Contract: May be
null.- Returns:
- the default value (possibly
null)
-
isGroupingAlias
boolean isGroupingAlias(@NotNull @NotNull java.lang.String alias)Returns whether the provided alias matches this variable (case-insensitive).Contract:
aliasmust be non-null.- Parameters:
alias- non-null alias to test- Returns:
- true if the alias matches this variable; otherwise false
- Throws:
java.lang.NullPointerException- ifaliasisnull
-
-