Skip to content

Instantly share code, notes, and snippets.

@cesarferreira
Created May 16, 2018 09:56
Show Gist options
  • Save cesarferreira/dd2c7342517877d3d711a22e637e379d to your computer and use it in GitHub Desktop.
Save cesarferreira/dd2c7342517877d3d711a22e637e379d to your computer and use it in GitHub Desktop.
public abstract class BaseMapperToPresentation<SOURCE, TARGET> {
/**
* Transforms a type into another
*
* @param toBeTransformed source that will be transformed
* @return the transformed object
*/
public abstract TARGET mapToPresentation(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> mapToPresentation(List<SOURCE> list) {
List<TARGET> targetList = new ArrayList<>();
for (SOURCE source : list) {
targetList.add(mapToPresentation(source));
}
return targetList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment