Skip to content

Commit

Permalink
Task 43 : Add Java Doc for Classes with Revision
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapter1990 committed Jul 2, 2024
1 parent 90edaa7 commit 3faf039
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/springboot/ratelimiter/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import lombok.*;
import lombok.experimental.SuperBuilder;

/**
* Domain Model class named {@link User} representing a User, extending from BaseDomainModel.
* Includes fields for id, name, and email.
*/
@Getter
@Setter
@SuperBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
* Mapper interface named {@link CreateUserRequestToUserEntityMapper} for converting {@link CreateUserRequest} to {@link UserEntity}.
* Extends BaseMapper for common mapping functionalities.
*/
@Mapper
public interface CreateUserRequestToUserEntityMapper extends BaseMapper<CreateUserRequest, UserEntity> {

/**
* Maps a CreateUserRequest object to a UserEntity object.
*
* @param createUserRequest the CreateUserRequest object to map
* @return the corresponding UserEntity object
*/
@Override
UserEntity map(CreateUserRequest createUserRequest);

/**
* Initializes the mapper instance using MapStruct's Mappers.getMapper() method.
*
* @return the initialized CreateUserRequestToUserEntityMapper instance
*/
static CreateUserRequestToUserEntityMapper initialize() {
return Mappers.getMapper(CreateUserRequestToUserEntityMapper.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
import java.util.List;
import java.util.stream.Collectors;

/**
* Mapper interface named {@link ListUserEntityToListUserMapper} for converting a List of UserEntity objects to a List of User objects.
*/
@Mapper
public interface ListUserEntityToListUserMapper {

UserEntityToUserMapper userEntityToUserMapper = Mappers.getMapper(UserEntityToUserMapper.class);

/**
* Converts a List of UserEntity objects to a List of User objects.
*
* @param userEntities the List of UserEntity objects to map
* @return the corresponding List of User objects
*/
default List<User> toUserList(List<UserEntity> userEntities) {

if (userEntities == null) {
Expand All @@ -25,7 +34,11 @@ default List<User> toUserList(List<UserEntity> userEntities) {

}


/**
* Initializes the mapper instance using MapStruct's Mappers.getMapper() method.
*
* @return the initialized ListUserEntityToListUserMapper instance
*/
static ListUserEntityToListUserMapper initialize() {
return Mappers.getMapper(ListUserEntityToListUserMapper.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

import com.springboot.ratelimiter.user.model.UserEntity;
import com.springboot.ratelimiter.user.payload.request.UpdateUserRequest;
import lombok.experimental.UtilityClass;

/**
* Utility class named {@link UpdateUserRequestToUserEntityMapper} for mapping UpdateUserRequest to UserEntity for update operations.
*/
@UtilityClass
public class UpdateUserRequestToUserEntityMapper {

public static UserEntity mapForUpdate(UserEntity userEntity, final UpdateUserRequest updateUserRequest) {
/**
* Maps fields from UpdateUserRequest to an existing UserEntity for update.
*
* @param userEntity the existing UserEntity to update
* @param updateUserRequest the UpdateUserRequest containing new data
* @return the updated UserEntity with fields from UpdateUserRequest
*/
public UserEntity mapForUpdate(UserEntity userEntity, final UpdateUserRequest updateUserRequest) {
userEntity.setName(updateUserRequest.getName());
userEntity.setEmail(updateUserRequest.getEmail());
return userEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
* Mapper interface named {@link UserEntityToUserMapper} for converting UserEntity to User.
* Extends BaseMapper for common mapping functionalities.
*/
@Mapper
public interface UserEntityToUserMapper extends BaseMapper<UserEntity, User> {

/**
* Maps a UserEntity object to a User object.
*
* @param source the UserEntity object to map
* @return the corresponding User object
*/
@Override
User map(UserEntity source);


/**
* Initializes the mapper instance using MapStruct's Mappers.getMapper() method.
*
* @return the initialized UserEntityToUserMapper instance
*/
static UserEntityToUserMapper initialize() {
return Mappers.getMapper(UserEntityToUserMapper.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
* Mapper interface named {@link UserToUserResponseMapper} for converting User to UserResponse.
* Extends BaseMapper for common mapping functionalities.
*/
@Mapper
public interface UserToUserResponseMapper extends BaseMapper<User, UserResponse> {

/**
* Maps a User object to a UserResponse object.
*
* @param source the User object to map
* @return the corresponding UserResponse object
*/
@Override
UserResponse map(User source);

/**
* Initializes the mapper instance using MapStruct's Mappers.getMapper() method.
*
* @return the initialized UserToUserResponseMapper instance
*/
static UserToUserResponseMapper initialize() {
return Mappers.getMapper(UserToUserResponseMapper.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import lombok.*;
import lombok.experimental.SuperBuilder;

/**
* Entity class named {@link UserEntity} representing a User, mapped to the "USERS" table.
* Includes fields for id, name, and email, with UUID generation for the id.
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import jakarta.validation.constraints.NotNull;
import lombok.*;

/**
* DTO named {@link CreateUserRequest} for creating a new user, including name and email fields with validation.
*/
@Getter
@Setter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import jakarta.validation.constraints.NotNull;
import lombok.*;

/**
* DTO named {@link UpdateUserRequest} for updating an existing user, including name and email fields with validation.
*/
@Getter
@Setter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import lombok.Setter;
import lombok.experimental.SuperBuilder;

/**
* DTO named {@link UserPagingRequest} for paginating user data, extending from CustomPagingRequest.
*/
@Getter
@Setter
@SuperBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import lombok.*;

/**
* DTO named {@link UserResponse} for user response, including id, name, and email fields.
*/
@Getter
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
import com.springboot.ratelimiter.user.model.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;

/**
* Repository interface named {@link UserRepository} for managing UserEntity entities.
*/
public interface UserRepository extends JpaRepository<UserEntity, String> {

/**
* Checks if a user exists by their email address.
*
* @param email the email address to check
* @return true if a user with the given email address exists, false otherwise
*/
boolean existsByEmail(String email);
}

0 comments on commit 3faf039

Please sign in to comment.