public static List transform(List fromList,
Function super F,? extends T> function
You might want to read up the API docs for Lists.transform() and Function, but basically the caller of the transform provides a Function
object that converts an F
to a T
.
For example if you have a List intList
and you want to create a List
such that each element of the latter contains the english representation of that number (1 becomes "one" etc) and you have a access to a class such as IntToEnglish then
Function intToEnglish =
new Function() {
public String apply(Integer i) { return new IntToEnglish().english_number(i); }
};
List wordsList = Lists.transform(intList, intToEnglish);
Does that conversion.
You can apply the same pattern to transform your List
to List