Suppose that you have a class A like follows:
public class A{
private B b;
public B getB(){return b;}
}
Then, you have a list of A objects and you want to create another list that contains the related B objects, i.e.
List<A> listOfA=...
List<B> listOfB = extractFrom(listOfA, "getB");
Exists a library that does the magic described by function extractFrom? Maybe it uses reflection, I don't know.
Or, maybe the library relies on an Extractor interface that uses generics, e.g.
public interface Extractor<T,V>{
public T extract(V source);
}
and then one does:
Extractor ex=...;
List<B> listOfB = extractFrom(listOfA, ex);
PS: The title is horrible! Please, edit the title so that it becomes more meaningfull.