private static <T> Entry<String, Function<Annotation, Val>> nullSafeEntry(
            final String fieldName,
            final Function<Annotation, T> getter,
            final Function<T, Val> creator) {

        Objects.requireNonNull(fieldName);
        Objects.requireNonNull(getter);
        return Map.entry(fieldName, annotation -> {
            T value = getter.apply(annotation);

            if (value == null) {
                return ValNull.INSTANCE;
            } else {
                if (creator != null) {
                    return creator.apply(value);
                } else if (value instanceof String) {
                    return ValString.create((String) value);
                } else if (value instanceof Long) {
                    return ValLong.create((Long) value);
                } else if (value instanceof final UserRef userRef) {
                    return ValString.create(userRef.toDisplayString());
                } else {
                    throw new RuntimeException("Unexpected type " + value.getClass().getName());
                }
            }
        });
    }
@param creator An explicit creator function to use rather than inferring it from the type.
stroom-annotation/stroom-annotation-impl/src/main/java/stroom/annotation/impl/AnnotationReceiverDecoratorFactory.java