How to call this pattern, and is there any existing apache-commons utility for this:
class Person {
String getName();
}
List<Person> persons = ...;
// create a dynamic bean on the fly, which can be used as:
Object personXxxx = transformListOfBeans(Person.class, persons);
// so each of the bean properties now returns the list of the original property:
List<String> personNames = personXxxx.name;
// i.e. the transformation creates a new "type":
class PersonXxxx {
List<String> getName();
}
How to call this kind of transformation? A proxy should keep the method signatures. So it is not a proxy, neither decorator.
Well, I can simply rename the generated property names to plural form, like:
personXxxx.names
This is no problem. I want to know if such pattern was already known so I don’t have to choose the appropriate words myself.
I don’t think a tool exists for this.
You have to code it :
Maybe you can use introspection to be more generic, but code is really simple.