mercredi 18 novembre 2015

How do i get a values from fields of a class which implements interface using reflection?

I'm reading all fields values from an object and his children:

private List<Object> getAllFieldsValues(Class<?> clazz, String[] filter) throws IllegalArgumentException, IllegalAccessException {
    List<Object> fieldsValues = new ArrayList<>();
    Field[] fields = clazz.getDeclaredFields();

    for (Field field : fields) {

        // some code

        if (field.getType().isInterface()) {
            // get all fields from a class which implements the interface
        }
    }
    return fieldsValues;
}

I need to get all values from class which implements the interface. How?





Aucun commentaire:

Enregistrer un commentaire