Package com.jk.core.jpa
Class JKEntityModelMapper
java.lang.Object
com.jk.core.jpa.JKEntityModelMapper
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
dateToString
(Date date) This method transform the givenDate
object into a string.void
fillCommonAttributesFromEntityToModel
(JKBaseEntity entity, JKBaseModel model) This method takes the providedJKBaseModel
attributes and fill them with values from the specifiedJKBaseEntity
attributes.void
fillCommonAttributesFromModelToEntity
(JKBaseEntity entity, JKBaseModel model) This method takes the providedJKBaseEntity
attributes and fill them with values from the specifiedJKBaseModel
attributes.static Date
stringToDate
(String date) This method transform the given date string into aDate
object.
-
Constructor Details
-
JKEntityModelMapper
public JKEntityModelMapper()
-
-
Method Details
-
fillCommonAttributesFromEntityToModel
This method takes the providedJKBaseModel
attributes and fill them with values from the specifiedJKBaseEntity
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
This method takes the providedJKBaseEntity
attributes and fill them with values from the specifiedJKBaseModel
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
This method transform the givenDate
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
This method transform the given date string into aDate
object.- Parameters:
date
- Specifies the date in theyyyy/MM/dd hh:mm:ss
format.- Returns:
- a
Date
object that represents the values in the provided string.
-