static boolean isOptional(Type type) {
    return type == Optional.class || type == OptionalDouble.class || type == OptionalLong.class || type == OptionalInt.class || (type instanceof ParameterizedType && ((ParameterizedType) type).getRawType() == Optional.class);
  }
Check if current type represents an optional type like {@link OptionalLong}, {@link Optional} etc.
criteria/mongo/src/org/immutables/criteria/mongo/Mongos.java