Class ProfileHelper


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static UserProfile buildUserProfileByClassCompleteName​(java.lang.String completeName)
      Build a profile by its class name.
      static <U extends UserProfile>
      java.util.List<U>
      flatIntoAProfileList​(java.util.Map<java.lang.String,​U> profiles)
      Flat the map of profiles into a list of profiles.
      static <U extends UserProfile>
      java.util.Optional<U>
      flatIntoOneProfile​(java.util.Collection<U> profiles)
      Flat the list of profiles into a single optional profile (skip any anonymous profile unless it's the only one).
      static java.util.List<java.lang.String> getProfileClassPrefixes()  
      static boolean isTypedIdOf​(java.lang.String id, java.lang.Class<? extends UserProfile> clazz)
      Indicate if the user identifier matches this kind of profile.
      static java.lang.String sanitizeIdentifier​(java.lang.Object id)
      Sanitize into a string identifier.
      static void setProfileClassPrefixes​(java.util.List<java.lang.String> profileClassPrefixes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isTypedIdOf

        public static boolean isTypedIdOf​(java.lang.String id,
                                          java.lang.Class<? extends UserProfile> 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
      • buildUserProfileByClassCompleteName

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

        public static <U extends UserProfile> java.util.Optional<U> flatIntoOneProfile​(java.util.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 UserProfile> java.util.List<U> flatIntoAProfileList​(java.util.Map<java.lang.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 java.lang.String sanitizeIdentifier​(java.lang.Object id)
        Sanitize into a string identifier.
        Parameters:
        id - the identifier object
        Returns:
        the sanitized identifier
      • getProfileClassPrefixes

        public static java.util.List<java.lang.String> getProfileClassPrefixes()
      • setProfileClassPrefixes

        public static void setProfileClassPrefixes​(java.util.List<java.lang.String> profileClassPrefixes)