All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.atleon.util.ValueResolution Maven / Gradle / Ivy

There is a newer version: 0.28.3
Show newest version
package io.atleon.util;

import java.lang.reflect.Field;

public final class ValueResolution {

    private ValueResolution() {

    }

    public static Object getFieldValue(Object target, Field field) {
        try {
            ensureFieldAccessibility(field);
            return field.get(target);
        } catch (Exception e) {
            throw new IllegalArgumentException(String.format("Failed to get Field Value: field=%s target=%s e=%s", field, target, e));
        }
    }

    private static void ensureFieldAccessibility(Field field) {
        if (!field.isAccessible()) {
            field.setAccessible(true);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy