private Optional getValueFromGetter()

in src/main/java/com/amazon/rdsdata/client/FieldMapper.java [69:83]


    private Optional<Object> getValueFromGetter(String fieldName) {
        val methodName = buildGetterName(fieldName);
        try {
            val method = getMethod(object, methodName);
            checkArgument(method.getReturnType() != void.class, ERROR_VOID_RETURN_TYPE_NOT_SUPPORTED);

            method.setAccessible(true);
            val result = method.invoke(object);
            return Optional.of(result == null ? NULL : result);
        } catch (NoSuchMethodException e) {
            return Optional.empty();
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new IllegalStateException("Cannot access method " + methodName + " from object " + object);
        }
    }