jeudi 28 novembre 2019

Convert model to List

I would like to find an efficient way of converting any object to the List<Object> of it's fields so for example:

public class User {
   private String name; // John
   private String surname; // Wick
   private int age; // 55
}

would end up as List with the next elements: {"John", "Wick", 55}.

I know I can do it using reflection but are there any ObjectUtils or ReflectionUtils methods that are already doing that?





Aucun commentaire:

Enregistrer un commentaire