blob: 85decd6369e21b06c9b9b88ce35a63b971f0b95b [file] [log] [blame]
package org.osbp.tests.dtos.mapper;
import org.eclipse.osbp.dsl.dto.lib.MappingContext;
import org.osbp.tests.dtos.DtoTestParentDto;
import org.osbp.tests.dtos.mapper.BaseUUIDDtoMapper;
import org.osbp.tests.entities.DtoTestParent;
/**
* This class maps the dto {@link DtoTestParentDto} to and from the entity {@link DtoTestParent}.
*
*/
@SuppressWarnings("all")
public class DtoTestParentDtoMapper<DTO extends DtoTestParentDto, ENTITY extends DtoTestParent> extends BaseUUIDDtoMapper<DTO, ENTITY> {
/**
* Creates a new instance of the entity
*/
public DtoTestParent createEntity() {
return new DtoTestParent();
}
/**
* Creates a new instance of the dto
*/
public DtoTestParentDto createDto() {
return new DtoTestParentDto();
}
/**
* Maps the entity {@link DtoTestParent} to the dto {@link DtoTestParentDto}.
*
* @param dto - The target dto
* @param entity - The source entity
* @param context - The context to get information about depth,...
*
*/
public void mapToDTO(final DtoTestParentDto dto, final DtoTestParent entity, final MappingContext context) {
if(context == null){
throw new IllegalArgumentException("Please pass a context!");
}
context.register(createDtoHash(entity), dto);
super.mapToDTO(dto, entity, context);
dto.setString(toDto_string(entity, context));
}
/**
* Maps the dto {@link DtoTestParentDto} to the entity {@link DtoTestParent}.
*
* @param dto - The source dto
* @param entity - The target entity
* @param context - The context to get information about depth,...
*
*/
public void mapToEntity(final DtoTestParentDto dto, final DtoTestParent entity, final MappingContext context) {
if(context == null){
throw new IllegalArgumentException("Please pass a context!");
}
context.register(createEntityHash(dto), entity);
context.registerMappingRoot(createEntityHash(dto), dto);
super.mapToEntity(dto, entity, context);
entity.setString(toEntity_string(dto, entity, context));
}
/**
* Maps the property string from the given entity to dto property.
*
* @param in - The source entity
* @param context - The context to get information about depth,...
* @return the mapped value
*
*/
protected String toDto_string(final DtoTestParent in, final MappingContext context) {
return in.getString();
}
/**
* Maps the property string from the given entity to dto property.
*
* @param in - The source entity
* @param parentEntity - The parentEntity
* @param context - The context to get information about depth,...
* @return the mapped value
*
*/
protected String toEntity_string(final DtoTestParentDto in, final DtoTestParent parentEntity, final MappingContext context) {
return in.getString();
}
public String createDtoHash(final Object in) {
return org.eclipse.osbp.runtime.common.hash.HashUtil.createObjectWithIdHash(DtoTestParentDto.class, in);
}
public String createEntityHash(final Object in) {
return org.eclipse.osbp.runtime.common.hash.HashUtil.createObjectWithIdHash(DtoTestParent.class, in);
}
}