Class RoleConverter

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

public class RoleConverter extends Object
A utility class for converting between Role and RoleDto objects.

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

  • Constructor Details

    • RoleConverter

      public RoleConverter()
  • Method Details

    • convertToRole

      public static Role convertToRole(RoleDto roleDto)
      Converts a RoleDto object to a Role entity.

      This method takes a RoleDto object containing role data and maps it to a Role entity, which can be saved to or retrieved from the database. The conversion includes all role-related fields like role name, associated users, permissions, and timestamps.

      Parameters:
      roleDto - the RoleDto object to be converted
      Returns:
      a Role entity populated with the values from the given RoleDto
    • convertToRoleDto

      public static RoleDto convertToRoleDto(Role role)
      Converts a Role entity to a RoleDto object.

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

      Parameters:
      role - the Role entity to be converted
      Returns:
      a RoleDto object populated with the values from the given Role