com.atlassian.crowd.embedded.impl
Class ImmutableUser

java.lang.Object
  extended by 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:
Serialized Form

Nested Class Summary
static class ImmutableUser.Builder
          Used to aid in the construction of an Immutable User object.
 
Constructor Summary
ImmutableUser(long directoryId, String name, String displayName, String emailAddress, boolean active)
           
 
Method Summary
 int compareTo(User other)
          CompareTo must be compatible with the equals() and hashCode() methods
 boolean equals(Object o)
          Implementations must ensure equality based on getDirectoryId() and case-insensitive getName().
 long getDirectoryId()
           
 String getDisplayName()
           
 String getEmailAddress()
           
 String getName()
           
 int hashCode()
          Implementations must produce a hashcode based on getDirectoryId() and case-insensitive getName().
 boolean isActive()
           
static ImmutableUser.Builder newUser()
           
static ImmutableUser.Builder newUser(User user)
          Creates a new User Builder by cloning the values from the supplied User.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.security.Principal
toString
 

Constructor Detail

ImmutableUser

public ImmutableUser(long directoryId,
                     @NotNull
                     String name,
                     String displayName,
                     String emailAddress,
                     boolean active)
Method Detail

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 User
Specified by:
equals in interface Principal
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 User
Specified by:
hashCode in interface Principal
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 User
Specified by:
compareTo in interface Comparable<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.


Copyright © 2013 Atlassian. All Rights Reserved.