Class SubjectType<I>

    • 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 name
        identifierType - explicit type of identifiers
        Returns:
        a builder for a subject type
        Since:
        2.0.0
      • builder

        public static <V> SubjectType.Builder<V> builder​(String name,
                                                         io.leangen.geantyref.TypeToken<V> identifierType)
        Create a new builder for subject types.
        Type Parameters:
        V - the identifier type
        Parameters:
        name - the subject type name
        identifierType - explicit type of identifiers
        Returns:
        a builder for a subject type
        Since:
        2.0.0
      • stringIdentBuilder

        public static SubjectType.Builder<StringstringIdentBuilder​(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 a InvalidIdentifierException when 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