| package org.osbp.mysmartshop.dtos.mapper; |
| |
| import org.eclipse.osbp.dsl.dto.lib.MappingContext; |
| import org.osbp.mysmartshop.dtos.TestDto; |
| import org.osbp.mysmartshop.dtos.mapper.BaseUUIDDtoMapper; |
| import org.osbp.mysmartshop.entities.Test; |
| |
| /** |
| * This class maps the dto {@link TestDto} to and from the entity {@link Test}. |
| * |
| */ |
| @SuppressWarnings("all") |
| public class TestDtoMapper<DTO extends TestDto, ENTITY extends Test> extends BaseUUIDDtoMapper<DTO, ENTITY> { |
| /** |
| * Creates a new instance of the entity |
| */ |
| public Test createEntity() { |
| return new Test(); |
| } |
| |
| /** |
| * Creates a new instance of the dto |
| */ |
| public TestDto createDto() { |
| return new TestDto(); |
| } |
| |
| /** |
| * Maps the entity {@link Test} to the dto {@link TestDto}. |
| * |
| * @param dto - The target dto |
| * @param entity - The source entity |
| * @param context - The context to get information about depth,... |
| * |
| */ |
| public void mapToDTO(final TestDto dto, final Test entity, final MappingContext context) { |
| if(context == null){ |
| throw new IllegalArgumentException("Please pass a context!"); |
| } |
| context.register(createDtoHash(entity), dto); |
| |
| super.mapToDTO(dto, entity, context); |
| |
| } |
| |
| /** |
| * Maps the dto {@link TestDto} to the entity {@link Test}. |
| * |
| * @param dto - The source dto |
| * @param entity - The target entity |
| * @param context - The context to get information about depth,... |
| * |
| */ |
| public void mapToEntity(final TestDto dto, final Test 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); |
| |
| } |
| |
| public String createDtoHash(final Object in) { |
| return org.eclipse.osbp.runtime.common.hash.HashUtil.createObjectWithIdHash(TestDto.class, in); |
| } |
| |
| public String createEntityHash(final Object in) { |
| return org.eclipse.osbp.runtime.common.hash.HashUtil.createObjectWithIdHash(Test.class, in); |
| } |
| } |