@Override public PropertyName findNameForDeserialization(Annotated a) { String name; // @JsonSetter has precedence over @JsonProperty, being more specific // @JsonDeserialize implies that there is a property, but no name JsonSetter js = _findAnnotation(a, JsonSetter.class); if (js != null) { name = js.value(); } else { JsonProperty pann = _findAnnotation(a, JsonProperty.class); if (pann != null) { name = pann.value(); /* 22-Apr-2014, tatu: Should figure out a better way to do this, but * it's actually bit tricky to do it more efficiently (meta-annotations * add more lookups; AnnotationMap costs etc) */ } else if (_hasAnnotation(a, JsonDeserialize.class) || _hasAnnotation(a, JsonView.class) || _hasAnnotation(a, JsonUnwrapped.class) // [#442] || _hasAnnotation(a, JsonBackReference.class) || _hasAnnotation(a, JsonManagedReference.class)) { name = ""; } else { return null; } } return PropertyName.construct(name); }
@Override public Boolean hasRequiredMarker(AnnotatedMember m) { JsonProperty ann = _findAnnotation(m, JsonProperty.class); if (ann != null) { return ann.required(); } return null; }
@Override public String findPropertyDefaultValue(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop == null) { return null; } String str = prop.defaultValue(); // Since annotations do not allow nulls, need to assume empty means "none" return str.isEmpty() ? null : str; }
@Override public Integer findPropertyIndex(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop != null) { int ix = prop.index(); if (ix != JsonProperty.INDEX_UNKNOWN) { return Integer.valueOf(ix); } } return null; }
@Override public PropertyName findNameForSerialization(Annotated a) { String name = null; JsonGetter jg = _findAnnotation(a, JsonGetter.class); if (jg != null) { name = jg.value(); } else { JsonProperty pann = _findAnnotation(a, JsonProperty.class); if (pann != null) { name = pann.value(); } else if (_hasAnnotation(a, JsonSerialize.class) || _hasAnnotation(a, JsonView.class) || _hasAnnotation(a, JsonRawValue.class)) { name = ""; } else { return null; } } return PropertyName.construct(name); }