类com.fasterxml.jackson.annotation.JsonManagedReference源码实例Demo

下面列出了怎么用com.fasterxml.jackson.annotation.JsonManagedReference的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: minnal   文件: BiDirectionalCollectionResolver.java
@Override
protected void setAttribute(Object pojo, AttributeMetaData attribute, Object value) {
    super.setAttribute(pojo, attribute, value);
    JsonManagedReference managedReference = attribute.getAnnotation(JsonManagedReference.class);
    if (managedReference != null && value != null) {
        Class<?> elementType = (Class<?>) attribute.getTypeArguments()[0];
        PropertyDescriptor backReference = getManagedBackReference(elementType, managedReference.value());
        if (backReference != null) {
            Collection collection = (Collection) value;
            for (Object object : collection) {
                try {
                    PropertyUtils.setProperty(object, backReference.getName(), pojo);
                } catch (Exception e) {
                    logger.info("Failed while setting the property {} on the class {}", backReference.getName(), value.getClass());
                }
            }

        }
    }
}
 
源代码2 项目: json-view   文件: JsonViewSerializer.java
/**
 * Returns a boolean indicating whether the provided field is annotated with
 * some form of ignore. This method is memoized to speed up execution time
 */
boolean annotatedWithIgnore(AccessibleProperty f) {
  return memoizer.annotatedWithIgnore(f, () -> {
    JsonIgnore jsonIgnore = getAnnotation(f, JsonIgnore.class);
    JsonIgnoreProperties classIgnoreProperties = getAnnotation(f.declaringClass, JsonIgnoreProperties.class);
    JsonIgnoreProperties fieldIgnoreProperties = null;
    boolean backReferenced = false;

    //make sure the referring field didn't specify properties to ignore
    if(referringField != null) {
      fieldIgnoreProperties = getAnnotation(referringField, JsonIgnoreProperties.class);
    }

    //make sure the referring field didn't specify a backreference annotation
    if(getAnnotation(f, JsonBackReference.class) != null && referringField != null) {
      for(AccessibleProperty lastField : getAccessibleProperties(referringField.declaringClass)) {
        JsonManagedReference fieldManagedReference = getAnnotation(lastField, JsonManagedReference.class);
        if(fieldManagedReference != null && lastField.type.equals(f.declaringClass)) {
          backReferenced = true;
          break;
        }
      }
    }

    return (jsonIgnore != null && jsonIgnore.value()) ||
        (classIgnoreProperties != null && asList(classIgnoreProperties.value()).contains(f.name)) ||
        (fieldIgnoreProperties != null && asList(fieldIgnoreProperties.value()).contains(f.name)) ||
        backReferenced;
  });
}
 
源代码3 项目: minnal   文件: BiDirectionalObjectResolver.java
@Override
protected void setAttribute(Object pojo, AttributeMetaData attribute, Object value) {
    super.setAttribute(pojo, attribute, value);
    JsonManagedReference managedReference = attribute.getAnnotation(JsonManagedReference.class);
    if (managedReference != null && value != null) {
        PropertyDescriptor backReference = getManagedBackReference(value.getClass(), managedReference.value());
        if (backReference != null) {
            try {
                PropertyUtils.setProperty(value, backReference.getName(), pojo);
            } catch (Exception e) {
                logger.info("Failed while setting the property {} on the class {}", backReference.getName(), value.getClass());
            }
        }
    }
}
 
源代码4 项目: AsuraFramework   文件: TUser.java
@JsonManagedReference
public Set<TArticle> getArticles() {
    return articles;
}
 
源代码5 项目: Spring-MVC-Blueprints   文件: BookedTrip.java
@JsonManagedReference("customer-data")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId", nullable = false)
public CustomerInfo getCustomerInfo() {
	return this.customerInfo;
}
 
源代码6 项目: Spring-MVC-Blueprints   文件: BookedTrip.java
@JsonManagedReference("booked-data")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tripId", nullable = false)
public Trip getTrip() {
	return this.trip;
}
 
源代码7 项目: mojito   文件: Drop.java
@JsonManagedReference
public Set<TranslationKit> getTranslationKits() {
    return translationKits;
}
 
源代码8 项目: streams   文件: GMailMessageActivitySerializer.java
@JsonManagedReference
@JsonIgnore
IMAPSSLStore getDefaultFolder();
 
源代码9 项目: streams   文件: GMailMessageActivitySerializer.java
@JsonManagedReference
@JsonIgnore
IMAPSSLStore getPersonalNamespaces();
 
源代码10 项目: streams   文件: GMailMessageActivitySerializer.java
@JsonManagedReference
@JsonIgnore
IMAPFolder getStore();
 
源代码11 项目: streams   文件: GMailMessageActivitySerializer.java
@JsonManagedReference
@JsonIgnore
@JsonBackReference
IMAPMessage getFolder();
 
源代码12 项目: streams   文件: GMailMessageActivitySerializer.java
@JsonManagedReference
@JsonIgnore
@JsonProperty("parent")
@JsonBackReference
MimeMultipart getParent();
 
源代码13 项目: attic-rave   文件: JpaPage.java
/**
 * Gets the widget containing {@link Region}s of the page
 *
 * @return Valid list of {@link Region}s
 */
@Override
@JsonManagedReference
public List<Region> getRegions() {
    return ConvertingListProxyFactory.createProxyList(Region.class, regions);
}
 
源代码14 项目: attic-rave   文件: JpaPage.java
@Override
@JsonManagedReference
public List<PageUser> getMembers() {
    return ConvertingListProxyFactory.createProxyList(PageUser.class, members);
}
 
源代码15 项目: attic-rave   文件: JpaRegion.java
/**
 * Gets the ordered list of widget instances for the region
 *
 * @return Valid list
 */
@Override
@JsonManagedReference
public List<RegionWidget> getRegionWidgets() {
    return ConvertingListProxyFactory.createProxyList(RegionWidget.class, regionWidgets);
}
 
源代码16 项目: gwt-jackson   文件: PropertyProcessor.java
private static Optional<PropertyInfo> processProperty( RebindConfiguration configuration, TreeLogger logger, JacksonTypeOracle
        typeOracle, PropertyAccessors propertyAccessors, BeanInfo beanInfo, boolean samePackage ) throws UnableToCompleteException {

    boolean getterAutoDetected = isGetterAutoDetected( configuration, propertyAccessors, beanInfo );
    boolean setterAutoDetected = isSetterAutoDetected( configuration, propertyAccessors, beanInfo );
    boolean fieldAutoDetected = isFieldAutoDetected( configuration, propertyAccessors, beanInfo );

    if ( !getterAutoDetected && !setterAutoDetected && !fieldAutoDetected && !propertyAccessors.getParameter().isPresent() ) {
        // none of the field have been auto-detected, we ignore the field
        return Optional.absent();
    }

    final String propertyName = propertyAccessors.getPropertyName();
    final JType type = findType( logger, propertyAccessors, typeOracle, getterAutoDetected, setterAutoDetected, fieldAutoDetected );

    PropertyInfoBuilder builder = new PropertyInfoBuilder( propertyName, type );

    builder.setIgnored( isPropertyIgnored( configuration, propertyAccessors, beanInfo, type, propertyName ) );
    if ( builder.isIgnored() ) {
        return Optional.of( builder.build() );
    }

    Optional<JsonProperty> jsonProperty = propertyAccessors.getAnnotation( JsonProperty.class );
    builder.setRequired( jsonProperty.isPresent() && jsonProperty.get().required() );

    Optional<JsonManagedReference> jsonManagedReference = propertyAccessors.getAnnotation( JsonManagedReference.class );
    builder.setManagedReference( Optional.fromNullable( jsonManagedReference.isPresent() ? jsonManagedReference.get()
            .value() : null ) );

    Optional<JsonBackReference> jsonBackReference = propertyAccessors.getAnnotation( JsonBackReference.class );
    builder.setBackReference( Optional.fromNullable( jsonBackReference.isPresent() ? jsonBackReference.get().value() : null ) );

    if ( !builder.getBackReference().isPresent() ) {
        determineGetter( propertyAccessors, samePackage, getterAutoDetected, fieldAutoDetected, builder );

        Optional<JsonRawValue> jsonRawValue = propertyAccessors.getAnnotation( JsonRawValue.class );
        builder.setRawValue( jsonRawValue.isPresent() && jsonRawValue.get().value() );
    }
    determineSetter( propertyAccessors, samePackage, setterAutoDetected, fieldAutoDetected, builder );

    Optional<JsonValue> jsonValue = propertyAccessors.getAnnotation( JsonValue.class );
    if ( jsonValue.isPresent() && jsonValue.get().value() && builder.getGetterAccessor().isPresent() && builder.getGetterAccessor()
            .get().getMethod().isPresent() ) {
        builder.setValue( true );
    }

    Optional<JsonAnyGetter> jsonAnyGetter = propertyAccessors.getAnnotation( JsonAnyGetter.class );
    if ( jsonAnyGetter.isPresent() && builder.getGetterAccessor().isPresent() && builder.getGetterAccessor().get().getMethod()
            .isPresent() ) {
        builder.setAnyGetter( true );
    }

    Optional<JsonAnySetter> jsonAnySetter = propertyAccessors.getAnnotation( JsonAnySetter.class );
    if ( jsonAnySetter.isPresent() && builder.getSetterAccessor().isPresent() && builder.getSetterAccessor().get().getMethod()
            .isPresent() && builder.getSetterAccessor().get().getMethod().get().getParameterTypes().length == 2 ) {
        builder.setAnySetter( true );
    }

    Optional<JsonUnwrapped> jsonUnwrapped = propertyAccessors.getAnnotation( JsonUnwrapped.class );
    if ( jsonUnwrapped.isPresent() && jsonUnwrapped.get().enabled() ) {
        builder.setUnwrapped( true );
    }

    processBeanAnnotation( logger, typeOracle, configuration, type, propertyAccessors, builder );

    builder.setFormat( propertyAccessors.getAnnotation( JsonFormat.class ) );

    Optional<JsonInclude> jsonInclude = propertyAccessors.getAnnotation( JsonInclude.class );
    if ( jsonInclude.isPresent() ) {
        builder.setInclude( Optional.of( jsonInclude.get().value() ) );
    } else {
        builder.setInclude( beanInfo.getInclude() );
    }

    Optional<JsonIgnoreProperties> jsonIgnoreProperties = propertyAccessors.getAnnotation( JsonIgnoreProperties.class );
    if ( jsonIgnoreProperties.isPresent() ) {
        builder.setIgnoreUnknown( Optional.of( jsonIgnoreProperties.get().ignoreUnknown() ) );
        if ( null != jsonIgnoreProperties.get().value() && jsonIgnoreProperties.get().value().length > 0 ) {
            builder.setIgnoredProperties( Optional.of( jsonIgnoreProperties.get().value() ) );
        }
    }

    return Optional.of( builder.build() );
}
 
@JsonManagedReference
public SimpleTreeNode2 getChild() {
    return child;
}
 
源代码18 项目: tutorials   文件: Author.java
@JsonManagedReference
public List<Item> getItems() {
    return items;
}
 
源代码19 项目: apigee-android-sdk   文件: ApigeeApp.java
@JsonManagedReference
public Set<AppConfigOverrideFilter> getAppConfigOverrideFilters() {
	return appConfigOverrideFilters;
}
 
 同包方法