public final class ClassUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Field |
getField(Class<?> targetClass,
String fieldName,
boolean recursive)
Gets the field with the given fieldName of the TargetClass making it accessible.
|
static <T> T |
getFieldValue(Object target,
String fieldName,
boolean recursive)
Gets a field value of a given object
|
public static Field getField(Class<?> targetClass, String fieldName, boolean recursive) throws NoSuchFieldException
targetClass - class to get the field from.fieldName - the name of the field.recursive - flag to lookup in subclasses or notNoSuchFieldException - when the request field does not exists.public static <T> T getFieldValue(Object target, String fieldName, boolean recursive) throws IllegalAccessException, NoSuchFieldException
T - the expected type of the field.target - object to get the field value fromfieldName - the name of the fieldrecursive - flag to lookup in subclassesIllegalAccessException - when the field is not reachableNoSuchFieldException - when the field does not existsCopyright © 2025. All rights reserved.