public static Object getValueFromFieldOrProperty(Object object, String paramName) {
        Class<?> aClass = object.getClass();
        final Optional<Field> optionalField = findField(aClass, paramName);
        if (optionalField.isPresent()) {
            return getValueFromField(optionalField.get(), object);
        }

        final Optional<Method> optionalGetMethod = findMethod(aClass, "get" + capitalize(paramName));
        if (optionalGetMethod.isPresent()) {
            return getValueFromGetMethod(optionalGetMethod.get(), object);
        }

        throw new IllegalArgumentException(String.format("Could not get value '%s' from object with class %s", paramName, object.getClass()));
    }
@Test
    void testGetValueFromFieldOrProperty() {
        final TestObject test = new TestObject("test");

        assertThat(getValueFromFieldOrProperty(test, "field")).isEqualTo("test");
        assertThat(getValueFromFieldOrProperty(test, "anotherField")).isEqualTo("test");
        assertThatThrownBy(() -> getValueFromFieldOrProperty(test, "doesNotExist")).isInstanceOf(IllegalArgumentException.class);
    }