Package de.xima.fc.user.presence
Class UserInfo
- java.lang.Object
-
- de.xima.fc.user.presence.UserInfo
-
- All Implemented Interfaces:
Serializable
public final class UserInfo extends Object implements Serializable
Represents a user in the system, including their id and display name. The display name can be localized using an i18n key. This class is immutable and equality is based on the user ID.- Since:
- 8.6.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UserInfoanonymous()Returns a UserInfo instance representing an anonymous user.static UserInfoanonymous(@NotNull UserId userId)Returns a UserInfo instance representing an anonymous user with a specific user ID.booleanequals(Object o)StringgetDisplayName(@NotNull Locale locale)Returns the display name localized to the given locale when a localization key is available.UserIdgetUserId()The id of a user.inthashCode()static UserInfoof(@NotNull UserId userId, @NotEmpty String displayName)Creates a new UserInfo instance with the specified user ID and display name.static UserInfosuperUser()Returns a UserInfo instance representing the super user.
-
-
-
Method Detail
-
getDisplayName
public String getDisplayName(@NotNull @NotNull Locale locale)
Returns the display name localized to the given locale when a localization key is available. If no display name is available, returns the user ID.- Parameters:
locale- The locale to use for localization.- Returns:
- The display name of the user, localized if possible.
- Since:
- 8.6.0
-
superUser
public static UserInfo superUser()
Returns a UserInfo instance representing the super user. The super user has a predefined user ID and a localized display name.- Returns:
- A UserInfo instance for the super user.
-
anonymous
public static UserInfo anonymous()
Returns a UserInfo instance representing an anonymous user. The anonymous user has a predefined user ID and a localized display name.- Returns:
- A UserInfo instance for an anonymous user.
-
anonymous
public static UserInfo anonymous(@NotNull @NotNull UserId userId)
Returns a UserInfo instance representing an anonymous user with a specific user ID. The anonymous user has a localized display name. This method allows for the creation of an anonymous user with a custom user ID, which can be useful in scenarios where the user ID needs to be specified for tracking or identification purposes.- Parameters:
userId- The user ID for the anonymous user.- Returns:
- A UserInfo instance for an anonymous user with the specified user ID.
-
of
public static UserInfo of(@NotNull @NotNull UserId userId, @NotEmpty @NotEmpty String displayName)
Creates a new UserInfo instance with the specified user ID and display name.- Parameters:
userId- The user ID for the new user.displayName- The display name for the new user.- Returns:
- A new UserInfo instance with the specified user ID and display name.
-
getUserId
public UserId getUserId()
The id of a user.- Since:
- 8.6.0
-
-