Class ImmutableUser

java.lang.Object
com.atlassian.crowd.embedded.impl.ImmutableUser
All Implemented Interfaces:
User, Serializable, Comparable<User>, Principal

public class ImmutableUser extends Object implements User, Serializable
A general purpose immutable implementation of the User interface. Note: This object does not allow null username or directoryId.
See Also:
  • Constructor Details

    • ImmutableUser

      public ImmutableUser(long directoryId, @Nonnull String name, String displayName, String emailAddress, boolean active)
  • Method Details

    • from

      public static ImmutableUser from(User user)
      Returns:
      an ImmutableUser with the same properties as the given user. Will avoid creating a copy if possible.
    • isActive

      public boolean isActive()
      Specified by:
      isActive in interface User
      Returns:
      true if and only if the user is allowed to authenticate.
    • getDirectoryId

      public long getDirectoryId()
      Specified by:
      getDirectoryId in interface User
      Returns:
      id of the directory in which the User is stored.
    • getName

      public String getName()
      Specified by:
      getName in interface Principal
    • getEmailAddress

      public String getEmailAddress()
      Specified by:
      getEmailAddress in interface User
      Returns:
      email address of the user.
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface User
      Returns:
      display name (eg. full name) of the user, must never be null.
    • equals

      public boolean equals(Object o)
      Description copied from interface: User
      Implementations must ensure equality based on getDirectoryId() and case-insensitive getName().
      Specified by:
      equals in interface Principal
      Specified by:
      equals in interface User
      Overrides:
      equals in class Object
      Parameters:
      o - object to compare to.
      Returns:
      true if and only if the directoryId and name.toLowerCase() of the directory entities match.
    • hashCode

      public int hashCode()
      Description copied from interface: User
      Implementations must produce a hashcode based on getDirectoryId() and case-insensitive getName().
      Specified by:
      hashCode in interface Principal
      Specified by:
      hashCode in interface User
      Overrides:
      hashCode in class Object
      Returns:
      hashcode.
    • compareTo

      public int compareTo(User other)
      Description copied from interface: User
      CompareTo must be compatible with the equals() and hashCode() methods
      Specified by:
      compareTo in interface Comparable<User>
      Specified by:
      compareTo in interface User
    • newUser

      public static ImmutableUser.Builder newUser()
    • newUser

      public static ImmutableUser.Builder newUser(User user)
      Creates a new User Builder by cloning the values from the supplied User.
      Parameters:
      user - user to be cloned.
      Returns:
      a User Builder containing the values from the supplied User.