Working in Properties
For example ,
You have an Object named Person.class and has properties id,name,surname …
You want to get the name value of your object.
Person benan = new Person();
benan.setName("Benan");
benan.setSurname("Aktas");You can get the value using getValue function like this :
String benanName = getValue(benan,"name").toString(); // benanName = "benan";
public static String getValue(Object E, String propertyName) {
String value = "";
try {
FieldProperty property = Properties.createProperty(E.getClass().getDeclaredField(propertyName));
if (property.getValue(E) != null)
value = property.getValue(E).toString();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
return value;
}