Skip to content

Instantly share code, notes, and snippets.

@cesarferreira
Created May 16, 2018 09:55
Show Gist options
  • Select an option

  • Save cesarferreira/12ac9f9d7fcd945d9590c8f83837fa20 to your computer and use it in GitHub Desktop.

Select an option

Save cesarferreira/12ac9f9d7fcd945d9590c8f83837fa20 to your computer and use it in GitHub Desktop.
BaseMapperToDomain
public abstract class BaseMapperToDomain<SOURCE, TARGET> {
/**
* Transforms a type into another
*
* @param toBeTransformed source that will be transformed
* @return the transformed object
*/
public abstract TARGET mapToDomain(SOURCE toBeTransformed);
/**
* Transforms a list of types into another type
*
* @param list list of sources that will be transformed
* @return the list of transformed objects
*/
public List<TARGET> mapToDomain(List<SOURCE> list) {
List<TARGET> targetList = new ArrayList<>();
for (SOURCE source : list) {
targetList.add(mapToDomain(source));
}
return targetList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment