public AnnotationMapping(String name, @Nullable T value) { this.name = name; this.value = value; } }
OptimizedConverter(String converter, String encoderField, @Nullable String nonNullableEncoderMethod, String decoderField, @Nullable String nonNullableDecoderMethod, @Nullable String defaultValue) { this.encoderField = converter + "." + encoderField; this.nonNullableEncoderMethod = nonNullableEncoderMethod != null ? converter + "." + nonNullableEncoderMethod : null; this.decoderField = converter + "." + decoderField; this.nonNullableDecoderMethod = nonNullableDecoderMethod != null ? converter + "." + nonNullableDecoderMethod : null; this.defaultValue = defaultValue; }
public MapEncoder( final DslJson json, final boolean checkForConversionToString, @Nullable final JsonWriter.WriteObject<K> keyEncoder, @Nullable final JsonWriter.WriteObject<V> valueEncoder) { if (json == null) throw new IllegalArgumentException("json can't be null"); this.json = json; this.checkForConversionToString = checkForConversionToString; this.keyEncoder = keyEncoder; this.valueEncoder = valueEncoder; }
public CollectionEncoder( final DslJson json, @Nullable final JsonWriter.WriteObject<E> encoder) { if (json == null) throw new IllegalArgumentException("json can't be null"); this.json = json; this.encoder = encoder; }
public ArrayEncoder( final DslJson json, @Nullable final JsonWriter.WriteObject<T> encoder) { if (json == null) throw new IllegalArgumentException("json can't be null"); this.json = json; this.encoder = encoder; }
static boolean isKnownType(@Nullable final Type type) { if (type == Object.class) return false; if (type instanceof Class<?>) { Class<?> manifest = (Class<?>)type; if (manifest.isInterface()) return false; return (manifest.getModifiers() & Modifier.ABSTRACT) == 0; } return type != null; }
@Nullable private TypeMirror findConverter(@Nullable AnnotationMirror dslAnn) { if (dslAnn == null) return null; Map<? extends ExecutableElement, ? extends AnnotationValue> values = dslAnn.getElementValues(); for (ExecutableElement ee : values.keySet()) { if (ee.toString().equals("converter()")) { TypeMirror mirror = (TypeMirror) values.get(ee).getValue(); return mirror != null && mirror.toString().equals(JsonAttribute.class.getName()) ? null : mirror; } } return null; }
@Nullable private String extractReturnType(Element element) { switch (element.getKind()) { case FIELD: return element.asType().toString(); case METHOD: return ((ExecutableElement) element).getReturnType().toString(); default: return null; } }
public boolean isFullMatch(Element property, @Nullable AnnotationMirror dslAnn) { if (dslAnn == null) return false; Map<? extends ExecutableElement, ? extends AnnotationValue> values = dslAnn.getElementValues(); for (ExecutableElement ee : values.keySet()) { if (ee.toString().equals("hashMatch()")) { Object val = values.get(ee).getValue(); return val != null && !((Boolean) val); } } return false; }
@Nullable public static TypeElement deserializeAs(AnnotationMirror annotation) { Map<? extends ExecutableElement, ? extends AnnotationValue> values = annotation.getElementValues(); for (ExecutableElement ee : values.keySet()) { if (ee.toString().equals("deserializeAs()")) { DeclaredType target = (DeclaredType) values.get(ee).getValue(); return (TypeElement) target.asElement(); } } return null; }
@Override public Object apply(@Nullable Object instance) { try { return field.get(instance); } catch (IllegalAccessException e) { throw new SerializationException("Unable to read field " + field.getName() + " of " + field.getDeclaringClass(), e); } } }
@Nullable public static String[] extractNames(Constructor<?> ctor) { if (ctor == null) throw new IllegalArgumentException("ctor can't be null"); return parameterNameExtractor.extractNames(ctor); }
private CompiledJson.ObjectFormatPolicy objectFormatPolicyValue(@Nullable AnnotationMirror annotation) { CompiledJson.ObjectFormatPolicy value = enumAnnotationElementValue(annotation, "objectFormatPolicy()", CompiledJson.ObjectFormatPolicy.class); return value != null ? value : CompiledJson.ObjectFormatPolicy.DEFAULT; }
public static void serialize(@Nullable final BigInteger value, final JsonWriter sw) { if (value == null) { sw.writeNull(); } else { sw.writeAscii(value.toString()); } }
public static <T, R> JsonWriter.WriteObject<T> createArrayEncoder( final Function<T, R> read, final DslJson json, @Nullable final Type type) { if (read == null) throw new IllegalArgumentException("read can't be null"); if (json == null) throw new IllegalArgumentException("json can't be null"); final JsonWriter.WriteObject<R> encoder = type != null ? json.tryFindWriter(type) : null; if (encoder == null || Object.class.equals(type)) return new LazyAttributeArrayEncoder<>(read, json, type); return new AttributeArrayEncoder<>(read, encoder); }
public static void serializeNullable(@Nullable final LocalDateTime value, final JsonWriter sw) { if (value == null) { sw.writeNull(); } else { serialize(value, sw); } }
public static void serializeNullable(@Nullable final OffsetDateTime value, final JsonWriter sw) { if (value == null) { sw.writeNull(); } else { serialize(value, sw); } }
public static void serializeNullable(@Nullable final LocalDateTime value, final JsonWriter sw) { if (value == null) { sw.writeNull(); } else { serialize(value, sw); } }
public static void serializeNullable(@Nullable final UUID value, final JsonWriter sw) { if (value == null) { sw.writeNull(); } else { serialize(value, sw); } }