Interface UserMapper


public interface UserMapper
Maps between generated API models and the internal user entity.

MapStruct generates the implementation at build time, keeping the mapping explicit and compile-time checked without hand-written boilerplate.

  • Method Summary

    Modifier and Type
    Method
    Description
    map(Instant instant)
    Converts persistence timestamps to API-friendly offset timestamps.
    toEntity(com.dmasone.identity.api.generated.model.CreateUserRequestV1 request)
    Converts a v1 creation request into a new user entity.
    toEntity(com.dmasone.identity.api.generated.model.CreateUserRequestV2 request)
    Converts a v2 creation request into a new user entity.
    com.dmasone.identity.api.generated.model.UserResponseV1
    toV1(User user)
    Converts a domain user into the version 1 API response.
    com.dmasone.identity.api.generated.model.UserResponseV2
    toV2(User user)
    Converts a domain user into the version 2 API response.
  • Method Details

    • toV1

      com.dmasone.identity.api.generated.model.UserResponseV1 toV1(User user)
      Converts a domain user into the version 1 API response.
      Parameters:
      user - persisted user entity
      Returns:
      user representation exposed by the v1 API
    • toV2

      com.dmasone.identity.api.generated.model.UserResponseV2 toV2(User user)
      Converts a domain user into the version 2 API response.
      Parameters:
      user - persisted user entity
      Returns:
      user representation exposed by the v2 API
    • toEntity

      User toEntity(com.dmasone.identity.api.generated.model.CreateUserRequestV1 request)
      Converts a v1 creation request into a new user entity.

      Generated identifiers, timestamps, status, and password hash are set by the service layer because they belong to application behavior, not request mapping.

      Parameters:
      request - validated v1 API request
      Returns:
      a new user entity ready for service enrichment
    • toEntity

      User toEntity(com.dmasone.identity.api.generated.model.CreateUserRequestV2 request)
      Converts a v2 creation request into a new user entity.
      Parameters:
      request - validated v2 API request
      Returns:
      a new user entity ready for service enrichment
    • map

      default OffsetDateTime map(Instant instant)
      Converts persistence timestamps to API-friendly offset timestamps.
      Parameters:
      instant - timestamp stored by the domain model
      Returns:
      UTC offset timestamp for generated OpenAPI responses