Class ProfileHelper


  • public final class ProfileHelper
    extends Object
    This class is an helper for profiles.
    Since:
    1.1.0
    Author:
    Jerome Leleu
    • Method Detail

      • isTypedIdOf

        public static boolean isTypedIdOf​(String id,
                                          Class<? extends CommonProfile> clazz)
        Indicate if the user identifier matches this kind of profile.
        Parameters:
        id - user identifier
        clazz - profile class
        Returns:
        if the user identifier matches this kind of profile
      • restoreOrBuildProfile

        public static CommonProfile restoreOrBuildProfile​(ProfileDefinition<? extends CommonProfile> profileDefinition,
                                                          String typedId,
                                                          Map<String,​Object> profileAttributes,
                                                          Map<String,​Object> authenticationAttributes,
                                                          Object... parameters)
        Restore or build a profile.
        Parameters:
        profileDefinition - the profile definition
        typedId - the typed identifier
        profileAttributes - The profile attributes. May be null.
        authenticationAttributes - The authentication attributes. May be null.
        parameters - additional parameters for the profile definition
        Returns:
        the restored or built profile
      • buildUserProfileByClassCompleteName

        public static CommonProfile buildUserProfileByClassCompleteName​(String completeName)
        Build a profile by its class name.
        Parameters:
        completeName - the class name
        Returns:
        the built user profile
      • flatIntoOneProfile

        public static <U extends UserProfileOptional<U> flatIntoOneProfile​(Collection<U> profiles)
        Flat the list of profiles into a single optional profile (skip any anonymous profile unless it's the only one).
        Type Parameters:
        U - the kind of profile
        Parameters:
        profiles - the list of profiles
        Returns:
        the (optional) profile
      • flatIntoAProfileList

        public static <U extends UserProfileList<U> flatIntoAProfileList​(Map<String,​U> profiles)
        Flat the map of profiles into a list of profiles.
        Type Parameters:
        U - the kind of profile
        Parameters:
        profiles - the map of profiles
        Returns:
        the list of profiles
      • sanitizeIdentifier

        public static String sanitizeIdentifier​(BasicUserProfile profile,
                                                Object id)
        Sanitize into a string identifier.
        Parameters:
        profile - the user profile
        id - the identifier object
        Returns:
        the sanitized identifier
      • setInternalAttributeHandler

        public static void setInternalAttributeHandler​(InternalAttributeHandler internalAttributeHandler)