Skip to content

Instantly share code, notes, and snippets.

@GrakovNe
Created July 24, 2018 07:42
Show Gist options
  • Select an option

  • Save GrakovNe/a3de4e9e74f046747182e172344b5ee5 to your computer and use it in GitHub Desktop.

Select an option

Save GrakovNe/a3de4e9e74f046747182e172344b5ee5 to your computer and use it in GitHub Desktop.
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