How to map Object field:value to attribute list?

150 Views Asked by At

ST has add(String name, Object value), but what if i want to populate ST attributes with data from POJO?

class User {
public String id;
public String link;
public String key;
}

So, i want to type something like ST.add(new User(...)) and get result:

ST.add("id", id);
ST.add("link", link);
...

As workaround i use Jackon ObjectMapper to map User.class to Map.class and then populate ST object with forEach.

0

There are 0 best solutions below