Class EnumContextDefinition<T extends Enum<T>>
- java.lang.Object
-
- ca.stellardrift.permissionsex.context.ContextDefinition<T>
-
- ca.stellardrift.permissionsex.context.EnumContextDefinition<T>
-
public abstract class EnumContextDefinition<T extends Enum<T>> extends ContextDefinition<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEnumContextDefinition(String name, Class<T> enumClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccumulateCurrentValues(CalculatedSubject subject, Consumer<T> consumer)Given a player, calculate active context types@Nullable Tdeserialize(String userValue)Given a string (which may be in user format), return a parsed object.booleanmatches(T ownVal, T testVal)Get whether two values match.Stringserialize(T canonicalValue)Given a parsed value, write data out as a string.Set<T>suggestValues(CalculatedSubject subject)Given a subject, suggest a set of values that may be valid for this context.-
Methods inherited from class ca.stellardrift.permissionsex.context.ContextDefinition
createValue, equals, hashCode, matches, name, toString
-
-
-
-
Constructor Detail
-
EnumContextDefinition
protected EnumContextDefinition(String name, Class<T> enumClass)
-
-
Method Detail
-
serialize
public final String serialize(T canonicalValue)
Description copied from class:ContextDefinitionGiven a parsed value, write data out as a string.- Specified by:
serializein classContextDefinition<T extends Enum<T>>- Parameters:
canonicalValue- Parsed value- Returns:
- serialized form of the value
-
deserialize
public final @Nullable T deserialize(String userValue)
Description copied from class:ContextDefinitionGiven a string (which may be in user format), return a parsed object.- Specified by:
deserializein classContextDefinition<T extends Enum<T>>- Parameters:
userValue- the value as a string, such as when provided by user input- Returns:
- V a deserialized value, or
null if unsuccessful
-
matches
public boolean matches(T ownVal, T testVal)
Description copied from class:ContextDefinitionGet whether two values match.- Overrides:
matchesin classContextDefinition<T extends Enum<T>>- Parameters:
ownVal- the defined valuetestVal- the value being tested against- Returns:
- whether
testValis an element ofownVal
-
accumulateCurrentValues
public void accumulateCurrentValues(CalculatedSubject subject, Consumer<T> consumer)
Description copied from class:ContextDefinitionGiven a player, calculate active context types- Specified by:
accumulateCurrentValuesin classContextDefinition<T extends Enum<T>>- Parameters:
subject- The subject active contexts are being calculated forconsumer- A function that will take the returned value and add it to the active context set
-
suggestValues
public Set<T> suggestValues(CalculatedSubject subject)
Description copied from class:ContextDefinitionGiven a subject, suggest a set of values that may be valid for this context. This need not be an exhaustive list, or could even be an empty list, but allows providing users possible suggestions to what sensible values for a context may be.- Overrides:
suggestValuesin classContextDefinition<T extends Enum<T>>- Parameters:
subject- a subject to query for environment information- Returns:
- a set of possible values
-
-