public static <T1, R> Optional<R> getAsOptional(final T1 value,
                                                    final Function<T1, R> getter) {
        if (value == null) {
            return Optional.empty();
        } else {
            return Optional.ofNullable(Objects.requireNonNull(getter).apply(value));
        }
    }
Apply getter to value if value is non-null and return wrapper in an {@link Optional}.
If this result or value are null return an empty {@link Optional}.
stroom-util-shared/src/main/java/stroom/util/shared/NullSafe.java