Class UserConverter

java.lang.Object
com.glowmart.shop_management.converter.UserConverter

public class UserConverter extends Object
A utility class for converting between User and UserDto objects.

This class provides static methods to convert a UserDto to a User and vice versa. The conversion maps all relevant fields between the two objects while ensuring consistency in data transformation.

  • Constructor Details

    • UserConverter

      public UserConverter()
  • Method Details

    • convertToUser

      public static User convertToUser(UserDto userDto)
      Converts a UserDto object to a User entity.

      This method takes a UserDto object containing user data and maps it to a User entity, which can be saved to or retrieved from the database. The conversion includes all user-related fields like username, email, phone number, password, and timestamps.

      Parameters:
      userDto - the UserDto object to be converted
      Returns:
      a User entity populated with the values from the given UserDto
    • convertToUserDto

      public static UserDto convertToUserDto(User user)
      Converts a User entity to a UserDto object.

      This method takes a User entity and maps its fields to a UserDto object. The DTO is typically used for transferring user data between different layers of the application, such as the service and presentation layers.

      Parameters:
      user - the User entity to be converted
      Returns:
      a UserDto object populated with the values from the given User