Hi: In our application, we extract some data from the database, for example, the table has columes: id, name, age, address, email.
Then we will get some of these properties according to customer.
If a client needs an identifier, name, we get an identifier, if you need a client identifier, name, age, we get an identifier, name, age.
Now we want to create a class to transfer these properties. However, we do not know exactly which field is being requested.
String[] requestPro={"name","id"}; //this field is specified by client Map<String, Object> map=new HashMap<String, Object>(); Entity en=Entity.newInstance(); for(String p:requestPro){ map.put(p, BeanUtils.getProperty(en, p)); }
Can I replace the card with a class here?
source share