コード例 #1
0
  @Override
  public void findAndAddVirtualProperties(
      MapperConfig<?> config, AnnotatedClass ac, List<BeanPropertyWriter> properties) {
    JsonAppend ann = _findAnnotation(ac, JsonAppend.class);
    if (ann == null) {
      return;
    }
    final boolean prepend = ann.prepend();
    JavaType propType = null;

    // First: any attribute-backed properties?
    JsonAppend.Attr[] attrs = ann.attrs();
    for (int i = 0, len = attrs.length; i < len; ++i) {
      if (propType == null) {
        propType = config.constructType(Object.class);
      }
      BeanPropertyWriter bpw = _constructVirtualProperty(attrs[i], config, ac, propType);
      if (prepend) {
        properties.add(i, bpw);
      } else {
        properties.add(bpw);
      }
    }

    // Then: general-purpose virtual properties?
    JsonAppend.Prop[] props = ann.props();
    for (int i = 0, len = props.length; i < len; ++i) {
      BeanPropertyWriter bpw = _constructVirtualProperty(props[i], config, ac);
      if (prepend) {
        properties.add(i, bpw);
      } else {
        properties.add(bpw);
      }
    }
  }
コード例 #2
0
 {
   location.add(new FoodOrgLocation());
 }