Extract List of Property / Field from List of Objects

Objective: To get list of a property from list of objects

Case:
Many times while working with database entities or beans we have a list of beans/entities though we need only list of ids or list of other field.
So we need to iterate from list and populate desired list.

To reduce these effort, a generic method that will do this job.

We have to pass list of beans and name of field we need.

Important: Bean class must have getter method for field need to be extracted

Here is simple method:

Continue reading

Advertisements