@Override
    public void write(JsonWriter out, Optional<E> value) throws IOException {
        if (value.isPresent()) {
            adapter.write(out, value.get());
        } else {
            out.nullValue();
        }
    }
use in GsonBuilder
instance.registerTypeAdapterFactory(OptionalTypeAdapter.FACTORY)

@author davey
@param <E>
fluent-mybatis-annotation/src/main/java/cn/org/atool/fluent/common/kits/gson/OptionalTypeAdapter.java