Class LegacyUserBridge


  • public final class LegacyUserBridge
    extends Object
    Converts between the legacy IUser and the shared kernel's User.

    Legacy code that needs to call into a bounded context converts its IUser here; a bounded context that has to call back into legacy core converts the other way. Both directions are adapters only — no logic beyond the conversion itself belongs in this class.

    Since:
    8.5.6
    Author:
    Norman Lorenz
    • Method Detail

      • toUser

        public static Optional<User> toUser​(IUser user)
        Converts a legacy IUser to the shared kernel's User.
        Parameters:
        user - the legacy user to convert. May be null, which yields an empty result — legacy code passes users around nullably.
        Returns:
        the converted User, or Optional.empty() if the given user was null or has no established identity.
        Since:
        8.5.6
      • toLegacyUser

        public static IUser toLegacyUser​(User user)
        Converts the shared kernel's User back to a legacy IUser.
        Parameters:
        user - the user to convert. Must not be null.
        Returns:
        the converted IUser.
        Since:
        8.5.6