コード例 #1
1
  @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);
  }
コード例 #2
0
  @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);
  }