Skip to content

GeneralMapper

seyyed edited this page Aug 5, 2021 · 1 revision

GeneralMapper

Mappers are used to convert DTOs to entities and vice versa. This is done automatically thanks to MapStruct framework

this class used for map compile time and used is the protocol that implement by mapStruct library version 1.3.1.Final you must create interface and extended it you must create interface and extended it

methode

public abstract T requestToBaseObject(S source);

source is the source of request view model

return the T is the Object

method used for cast request to BaseObject

public abstract S toRequestModel(T target)

target the BaseObject of object

return the Request view model

method used for cast BaseObject to Response View Model

public abstract List< T > requestToBaseObject(List< S > sourceList)

sourceList the list of Request view Model

return the list of BaseObject

method used for cast List Response View Model to List BaseObject

public abstract List< S > toRequestModel(List< R > targetList)

targetList the list of Response View Model

return the List Of Request View Model

method used for cast List Response View Model to List Request View Model

public abstract List< S > toRequestModels(List< T > targetList)

targetList the List Of BaseObject

return the List of Response View Model

method used for cast Iterable Of BaseObject to List Of Request View Model

public abstract T responseToBaseObject(R source)

source the Response View Model

return the BaseObject

method used for cast Response To BaseObject

public abstract R toResponseModel(T target)

target the BaseObject Object

return the Response View Model

method used for cast BaseObject to Response

public abstract List< T > responseToBaseObject(List< R > sourceList)

sourceList the List Of Response View Model

return the list Of BaseObject

used for cast Iterable of Response to List Of BaseObject

public abstract List< R > toResponseModel(List< T > targetList)

targetList the List of BaseObject

return the List Of Response View Model

used for cast to Iterable of BaseObject to List Of Response

Example

@Mapper(componentModel = "spring")
@Component
public abstract class AffairMapper extends GeneralMapper<Affair, AffairReqVM, AffairResVM, Long> {
}