Interface ChallengeMapper
public interface ChallengeMapper
Mapper interface for converting back and forth
from a DTO to a Challenge entity.
- Since:
- 18.4.2024
- Version:
- 1.0
- Author:
- Yasin M.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ChallengeMapper
Implementation instance of the mapper -
Method Summary
Modifier and TypeMethodDescriptiondefault String
Formats type of challenge to capitalized first letterConverts from Challenge entity to DTO.toEntity
(ChallengeCreateDTO challengeCreateDTO, User user) Converts from challenge DTO to entity.updateEntity
(Challenge challenge, ChallengeUpdateDTO challengeDTO) Updates a challenge entity using dto.default void
updateType
(Challenge challenge, ChallengeUpdateDTO challengeDTO) Sets the type of challenge to null if DTO type is null
-
Field Details
-
INSTANCE
Implementation instance of the mapper
-
-
Method Details
-
toDTO
Converts from Challenge entity to DTO. Calculates completion value as percentage of saved amount to target amount- Parameters:
challenge
- Challenge entity- Returns:
- Converted DTO
-
toEntity
Converts from challenge DTO to entity. Ignore null values. Calculates completion value as percentage of saved amount to target amount. Type is capitalized only on first letter.- Parameters:
challengeCreateDTO
- Challenge DTOuser
- User who owns the challenge- Returns:
- Converted challenge entity
-
updateEntity
Updates a challenge entity using dto. Ignore null values. Calculates completion value as percentage of saved amount to target amount. Type is capitalized only on first letter.- Parameters:
challenge
- Challenge entity that is updatedchallengeDTO
- DTO with new changes- Returns:
- Updated challenge entity
-
getType
Formats type of challenge to capitalized first letter- Parameters:
type
- Unformatted type- Returns:
- Formatted type
-
updateType
Sets the type of challenge to null if DTO type is null- Parameters:
challenge
- Challenge entitychallengeDTO
- Challenge DTO
-