Class DTOMapping<M,T>
java.lang.Object
it.unimib.unimibmodules.controller.DTOMapping<M,T>
- Direct Known Subclasses:
CloseEndedAnswerController
,DTOListMapping
,SurveyController
,UserController
Defines the method that will be used by controllers to convert an instance of M (the model) to an instance of T (the
DTO) and vice versa.
- Version:
- 0.4.1
- Author:
- Davide Costantini, Luca Milazzo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.modelmapper.ModelMapper
The instance of modelMapper that will be used to convert Question to QuestionDTO and vice versa. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract T
convertToDTO
(M value) Converts an instance of M to an instance of Tabstract M
convertToEntity
(T dto) Converts an instance of T to an instance of M
-
Field Details
-
modelMapper
protected final org.modelmapper.ModelMapper modelMapperThe instance of modelMapper that will be used to convert Question to QuestionDTO and vice versa.
-
-
Constructor Details
-
DTOMapping
@Autowired protected DTOMapping(org.modelmapper.ModelMapper modelMapper)
-
-
Method Details
-
convertToDTO
Converts an instance of M to an instance of T- Parameters:
value
- an instance of M- Returns:
- an instance of T, containing the serialized data of value
-
convertToEntity
public abstract M convertToEntity(T dto) throws FormatException, EmptyFieldException, NotFoundException, IncorrectSizeException Converts an instance of T to an instance of M- Parameters:
dto
- an instance of T- Returns:
- an instance of M, containing the deserialized data of T
- Throws:
FormatException
EmptyFieldException
- when one of the required field is emptyNotFoundException
- when one of the queries failsIncorrectSizeException
-