diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/domain/user/UserRegistry.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/domain/user/UserRegistry.java index adb1abe..bc0cd36 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/domain/user/UserRegistry.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/domain/user/UserRegistry.java @@ -86,15 +86,38 @@ public class UserRegistry { } /** - * Looks up a user by their session ID. + * Looks up a user by their {@link SessionId}. * - * @param sessionId the session ID to look up - * @return an Optional containing the user, or empty if no user is associated with this session + * @param sessionId the SessionId to look up + * @return an Optional containing the {@link User}, or empty if no user is associated with this + * SessionId */ - public Optional findBySessionId(SessionId sessionId) { + public Optional getBySessionId(SessionId sessionId) { return Optional.ofNullable(bySessionId.get(sessionId)); } + /** + * Looks up a user by their {@link UserId}. + * + * @param userId the UserId to look up + * @return an Optional containing the {@link User}, or empty if no user is associated with this + * UserId + */ + public Optional getByUserId(UserId userId) { + return Optional.ofNullable(byId.get(userId)); + } + + /** + * Looks up a user by their username. + * + * @param username the username to look up + * @return an Optional containing the {@link User}, or empty if no user is associated with this + * username + */ + public Optional getByUsername(String username) { + return Optional.ofNullable(byName.get(username)); + } + /** * Returns all currently registered users. *