Skip to content

Instantly share code, notes, and snippets.

@bholota
Created August 11, 2016 10:07
Show Gist options
  • Save bholota/4d2891374bc866df1caa5873a84f6323 to your computer and use it in GitHub Desktop.
Save bholota/4d2891374bc866df1caa5873a84f6323 to your computer and use it in GitHub Desktop.
WannaBeFunctional
private static abstract class Transform1<T, M> {
abstract M transform(T input);
}
private <InputType, OutputType, InputList extends List<InputType>, OutputList extends List<OutputType>> OutputList map (InputList input, Transform1<InputType, OutputType> transform1) {
List<OutputType> out = new ArrayList<>();
for (InputType i : input) {
out.add(transform1.transform(i));
}
//noinspection unchecked
return (OutputList)out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment