Class JKEntityModelMapper

java.lang.Object
com.jk.core.jpa.JKEntityModelMapper

public class JKEntityModelMapper extends Object
This class provides methods for JKBaseEntity objects and JKBaseModel objects to interact with each other by mapping each other attributes to their own.

This class also provide methods to convert dates to strings and vice versa.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKEntityModelMapper

      public JKEntityModelMapper()
  • Method Details

    • fillCommonAttributesFromEntityToModel

      public void fillCommonAttributesFromEntityToModel(JKBaseEntity entity, JKBaseModel model)
      This method takes the provided JKBaseModel attributes and fill them with values from the specified JKBaseEntity attributes.
      Parameters:
      entity - Specifies the entity whose attributes values are to be copied.
      model - Specifies the model whose attributes are to be changed to the new values taken from the entity.
    • fillCommonAttributesFromModelToEntity

      public void fillCommonAttributesFromModelToEntity(JKBaseEntity entity, JKBaseModel model)
      This method takes the provided JKBaseEntity attributes and fill them with values from the specified JKBaseModel attributes.
      Parameters:
      entity - Specifies the entity whose attributes are to be changed to the new values taken from the model.
      model - Specifies the model whose attributes values are to be copied.
    • dateToString

      public static String dateToString(Date date)
      This method transform the given Date object into a string.

      This method formats the date in the following format:

      yyyy/MM/dd hh:mm:ss

      Parameters:
      date - Specifies the date to be converted.
      Returns:
      string representation of the date.
    • stringToDate

      public static Date stringToDate(String date)
      This method transform the given date string into a Date object.
      Parameters:
      date - Specifies the date in the yyyy/MM/dd hh:mm:ss format.
      Returns:
      a Date object that represents the values in the provided string.