/** * This method return all the fields (including private) from the given class and its super * classes. * * @param fieldClass Class * @return List<Field> * @should return all fields include private and super classes */ public static List<Field> getAllFields(Class<?> fieldClass) { List<Field> fields = ClassDataCacher.getInstance().getClassData(fieldClass).getFields(); return new ArrayList<>(fields); }
/** * Get the field if it exists for this class * @param cd the class data cache object * @param name the name of the field * @return the field if found OR null if not */ protected Field getFieldIfPossible(ClassData<?> cd, String name) { Field f = null; List<Field> fields = cd.getFields(); for (Field field : fields) { if (field.getName().equals(name)) { f = field; break; } } return f; }
/** * Get the field if it exists for this class * @param cd the class data cache object * @param name the name of the field * @return the field if found OR null if not */ protected Field getFieldIfPossible(ClassData<?> cd, String name) { Field f = null; List<Field> fields = cd.getFields(); for (Field field : fields) { if (field.getName().equals(name)) { f = field; break; } } return f; }
/** * Populates the fields from the class data object * @param includeNonPublic if true then all fields will be used, if false then only public fields */ private void populateFields(boolean includeNonPublic) { // set the fields List<Field> fields; if (includeNonPublic) { fields = classData.getFields(); } else { fields = classData.getPublicFields(); } for (Field field : fields) { if (! includeStaticFields && isStatic(field)) { continue; // skip statics } String fieldName = field.getName(); if (ignoredFieldNames.contains(fieldName)) { continue; // skip ignored names } if (! namesToProperties.containsKey(fieldName)) { ClassProperty p = new ClassProperty(fieldName, field); namesToProperties.put(fieldName, p); } } }
/** * Populates the fields from the class data object * @param includeNonPublic if true then all fields will be used, if false then only public fields */ private void populateFields(boolean includeNonPublic) { // set the fields List<Field> fields; if (includeNonPublic) { fields = classData.getFields(); } else { fields = classData.getPublicFields(); } for (Field field : fields) { if (! includeStaticFields && isStatic(field)) { continue; // skip statics } String fieldName = field.getName(); if (ignoredFieldNames.contains(fieldName)) { continue; // skip ignored names } if (! namesToProperties.containsKey(fieldName)) { ClassProperty p = new ClassProperty(fieldName, field); namesToProperties.put(fieldName, p); } } }
for (Field field : classData.getFields()) { try { String fieldName = field.getName();
for (Field field : classData.getFields()) { try { String fieldName = field.getName();