Class SubjectType<I>
- java.lang.Object
-
- ca.stellardrift.permissionsex.subject.SubjectType<I>
-
- Type Parameters:
I- identifier type
public final class SubjectType<I> extends Object
A definition for parameters controlling aSubjectTypeCollection's handling.- Since:
- 2.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSubjectType.Builder<I>A builder for a subject type
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> SubjectType.Builder<V>builder(String name, Class<V> identifierType)Create a new builder for subject types.booleanequals(Object other)@Nullable ObjectgetAssociatedObject(I identifier)The native object that may be heldinthashCode()booleanisIdentifierValid(String serialized)Check if a name is a valid identifier for a given subject collectionStringname()The name of the subject type this defines.IparseIdentifier(String input)Parse an identifier given its serialized string representation.@Nullable IparseOrCoerceIdentifier(String name)Attempt to parse an identifier, while also attempting to resolve from any user-friendly display name that may be available.StringserializeIdentifier(I input)Serialize an identifier to its canonical represenattion.static SubjectType.Builder<String>stringIdentBuilder(String name)Create a new builder for subject types using a string identifier.StringtoString()booleantransientHasPriority()Return whether or not transient data takes priority over persistent for this subject type.booleanundefinedPermissionValue(I identifier)The boolean value an undefined permission should have for this subject type
-
-
-
Method Detail
-
builder
public static <V> SubjectType.Builder<V> builder(String name, Class<V> identifierType)
Create a new builder for subject types.- Type Parameters:
V- the identifier type- Parameters:
name- the subject type nameidentifierType- explicit type of identifiers- Returns:
- a builder for a subject type
- Since:
- 2.0.0
-
stringIdentBuilder
public static SubjectType.Builder<String> stringIdentBuilder(String name)
Create a new builder for subject types using a string identifier.- Parameters:
name- the subject type name- Returns:
- a builder for a subject type
- Since:
- 2.0.0
-
name
public final String name()
The name of the subject type this defines.- Returns:
- the type name
- Since:
- 2.0.0
-
transientHasPriority
public final boolean transientHasPriority()
Return whether or not transient data takes priority over persistent for this subject type.- Returns:
- Whether or not transient data has priority.
- Since:
- 2.0.0
-
isIdentifierValid
public boolean isIdentifierValid(String serialized)
Check if a name is a valid identifier for a given subject collection- Parameters:
serialized- The identifier to check- Returns:
- Whether or not the given name is a valid identifier
-
parseIdentifier
public I parseIdentifier(String input)
Parse an identifier given its serialized string representation.- Parameters:
input- the serialized form- Returns:
- a parsed identifier
- Throws:
InvalidIdentifierException- if an identifier is not of appropriate format for this subject type.
-
serializeIdentifier
public String serializeIdentifier(I input)
Serialize an identifier to its canonical represenattion.- Parameters:
input- the identifier- Returns:
- the canonical representation of the identifier
-
parseOrCoerceIdentifier
public @Nullable I parseOrCoerceIdentifier(String name)
Attempt to parse an identifier, while also attempting to resolve from any user-friendly display name that may be available.Unlike
parseIdentifier(String), this will not throw aInvalidIdentifierExceptionwhen identifiers are of an invalid format. Instead it may attempt to perform some sort of lookup to resolve an identifier from the provided information.- Parameters:
name- The friendly name that may be used- Returns:
- A standard representation of the subject identifier
-
getAssociatedObject
public @Nullable Object getAssociatedObject(I identifier)
The native object that may be held- Parameters:
identifier- type- Returns:
- A native object that has its permissions defined by this subject
-
undefinedPermissionValue
public boolean undefinedPermissionValue(I identifier)
The boolean value an undefined permission should have for this subject type
-
-