Created
July 24, 2018 07:42
-
-
Save GrakovNe/a3de4e9e74f046747182e172344b5ee5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package net.thumbtack.adtech.campaign.manager.api.converter; | |
| import org.springframework.stereotype.Service; | |
| import java.util.stream.Collectors; | |
| import net.thumbtack.adtech.campaign.manager.api.response.dictonaries.HierarchyIdNameResponse; | |
| import net.thumbtack.adtech.campaign.manager.domain.GoogleHierarchyTargetingEntity; | |
| /** | |
| * GoogleHierarchyTargetingConverter. | |
| * | |
| * @param <Entity> GoogleHierarchyTargetingEntity | |
| */ | |
| @Service | |
| public class GoogleHierarchyTargetingConverter<Entity extends GoogleHierarchyTargetingEntity<Entity>> | |
| implements ResponseConverter<Entity, HierarchyIdNameResponse> { | |
| @Override | |
| public HierarchyIdNameResponse from(Entity entity) { | |
| HierarchyIdNameResponse result = new HierarchyIdNameResponse(); | |
| result.setId(entity.getId()); | |
| result.setName(entity.getName()); | |
| result.setChildren(entity.getChildren().stream().map(this::from).collect(Collectors.toSet())); | |
| return result; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment