/** * creates entity BuildingKit from this dto object * * @param buildingKitDto brick DTO object * @return BuildingKit entity */ public static BuildingKit convertToEntity(BuildingKitDto buildingKitDto) { if (buildingKitDto == null) { throw new IllegalArgumentException("Dto can not be NULL"); } BuildingKit kit = new BuildingKit(); kit.setId(buildingKitDto.getId()); kit.setDescription(buildingKitDto.getDescription()); kit.setName(buildingKitDto.getName()); kit.setYearFrom(buildingKitDto.getYearFrom()); kit.setPrice(buildingKitDto.getPrice()); ThemeSetDto themeSet = buildingKitDto.getThemeSet(); if (themeSet != null) { kit.setThemeSet(ThemeSetConversion.convertToEntity(themeSet)); } CategoryDto category = buildingKitDto.getCategory(); if (category != null) { kit.setCategory(CategoryConversion.convertToEntity(category)); } Map<Brick, Integer> brickEntities = new HashMap<Brick, Integer>(); Map<BrickDto, Integer> bricks = buildingKitDto.getBricks(); if (bricks != null) { for (BrickDto br : bricks.keySet()) { brickEntities.put(BrickConversion.convertToEntity(br), bricks.get(br)); } kit.setBricks(brickEntities); } return kit; }