当前位置: 首页>>代码示例>>Java>>正文


Java JsonBackReference类代码示例

本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonBackReference的典型用法代码示例。如果您正苦于以下问题:Java JsonBackReference类的具体用法?Java JsonBackReference怎么用?Java JsonBackReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonBackReference类属于com.fasterxml.jackson.annotation包,在下文中一共展示了JsonBackReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processFields

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
/**
 * Processes all fields of a class
 * 
 * @param fields
 *            array of fields
 * @param definition
 *            current definition
 * @param rootDefinition
 *            definition where the recursion started to prevent an endless
 *            loop
 * @return list of {@link Property} objects
 * @throws ParserException
 *             Error while the parsing process
 */
public List<Property> processFields(Field[] fields, Definition definition, Definition rootDefinition)
        throws ParserException {
    DataTypeFactory typeHandler = new DataTypeFactory();
    List<Property> properties = new ArrayList<>();
    for (Field field : fields) {
        if (field.getAnnotation(JsonIgnore.class) == null && field.getAnnotation(JsonBackReference.class) == null) {
            Property property = new Property();
            Class<?> typeClass = field.getType();
            Annotation[] annotations = field.getAnnotations();
            Type genericType = field.getGenericType();
            processGenerics(genericType, property, definition, rootDefinition);
            DataType typeObject = typeHandler.getDataType(typeClass.getName());
            String type = typeObject.getType();
            String name = field.getName();
            property.setName(name);
            if (type.length() > 14 && (type.substring(14).equals(definition.getClassName())
                    || type.substring(14).equals(rootDefinition.getClassName()))) {
                property.setReference(type);
            } else if (type.startsWith("#")) {
                createDefinitionBySchemaAndPackageIfNotExists(type, typeClass.getTypeName(), rootDefinition);
                property.setReference(type);
            } else {
                property.setType(type);
                property.setFormat(typeObject.getFormat());
            }
            properties.add(property);
            processAnnotations(annotations, definition, name);
        }
    }
    return properties;
}
 
开发者ID:SPIRIT-21,项目名称:javadoc2swagger,代码行数:46,代码来源:DefinitionParser.java

示例2: annotatedWithIgnore

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
/**
 * 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(Field f) {
  return memoizer.ignoreAnnotations(f, () -> {
    JsonIgnore jsonIgnore = getAnnotation(f, JsonIgnore.class);
    JsonIgnoreProperties classIgnoreProperties = getAnnotation(f.getDeclaringClass(), 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(Field lastField : getDeclaredFields(referringField.getDeclaringClass())) {
        JsonManagedReference fieldManagedReference = getAnnotation(lastField, JsonManagedReference.class);
        if(fieldManagedReference != null && lastField.getType().equals(f.getDeclaringClass())) {
          backReferenced = true;
          break;
        }
      }
    }

    return (jsonIgnore != null && jsonIgnore.value()) ||
        (classIgnoreProperties != null && Arrays.asList(classIgnoreProperties.value()).contains(f.getName())) ||
        (fieldIgnoreProperties != null && Arrays.asList(fieldIgnoreProperties.value()).contains(f.getName())) ||
        backReferenced;
  });
}
 
开发者ID:monitorjbl,项目名称:json-view,代码行数:34,代码来源:JsonViewSerializer.java

示例3: getMeeting

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@Id
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "meeting_id")
@JsonBackReference
public Meeting getMeeting() {
  return meeting;
}
 
开发者ID:wisobi,项目名称:leanbean,代码行数:8,代码来源:Vote.java

示例4: findDeserializationName

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
public String findDeserializationName(AnnotatedField paramAnnotatedField)
{
  JsonProperty localJsonProperty = (JsonProperty)paramAnnotatedField.getAnnotation(JsonProperty.class);
  if (localJsonProperty != null)
    return localJsonProperty.value();
  if ((paramAnnotatedField.hasAnnotation(JsonDeserialize.class)) || (paramAnnotatedField.hasAnnotation(JsonView.class)) || (paramAnnotatedField.hasAnnotation(JsonBackReference.class)) || (paramAnnotatedField.hasAnnotation(JsonManagedReference.class)))
    return "";
  return null;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:10,代码来源:JacksonAnnotationIntrospector.java

示例5: findReferenceType

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
public AnnotationIntrospector.ReferenceProperty findReferenceType(AnnotatedMember paramAnnotatedMember)
{
  JsonManagedReference localJsonManagedReference = (JsonManagedReference)paramAnnotatedMember.getAnnotation(JsonManagedReference.class);
  if (localJsonManagedReference != null)
    return AnnotationIntrospector.ReferenceProperty.managed(localJsonManagedReference.value());
  JsonBackReference localJsonBackReference = (JsonBackReference)paramAnnotatedMember.getAnnotation(JsonBackReference.class);
  if (localJsonBackReference != null)
    return AnnotationIntrospector.ReferenceProperty.back(localJsonBackReference.value());
  return null;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:11,代码来源:JacksonAnnotationIntrospector.java

示例6: getManagedBackReference

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
private PropertyDescriptor getManagedBackReference(Class<?> clazz, String name) {
    List<PropertyDescriptor> descriptors = PropertyUtil.getPopertiesWithAnnotation(clazz, JsonBackReference.class);
    if (descriptors != null) {
        for (PropertyDescriptor descriptor : descriptors) {
            JsonBackReference backReference = PropertyUtil.getAnnotation(descriptor, JsonBackReference.class);
            if (backReference.value().equals(name)) {
                return descriptor;
            }
        }
    }
    return null;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:13,代码来源:BiDirectionalObjectResolver.java

示例7: setup

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@BeforeMethod
public void setup() {
	convertor = spy(new ExcludeAnnotationsConvertor(Lists.<Class<? extends Annotation>>newArrayList(JsonBackReference.class)));
	model = mock(Model.class);
	properties = mock(LinkedHashMap.class);
	when(model.properties()).thenReturn(properties);
}
 
开发者ID:minnal,项目名称:minnal,代码行数:8,代码来源:ExcludeAnnotationsConvertorTest.java

示例8: getCustomer

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="customerNumber", nullable=false)
@JsonBackReference("order-customer")
public Customer getCustomer() {
    return this.customer;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:Order.java

示例9: getOrder

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="orderNumber", nullable=false, insertable=false, updatable=false)
@JsonBackReference("orderdetail-order")
public Order getOrder() {
    return this.order;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:OrderDetail.java

示例10: getProduct

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="productCode", nullable=false, insertable=false, updatable=false)
@JsonBackReference("order-product")
public Product getProduct() {
    return this.product;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:OrderDetail.java

示例11: getUser

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public TUser getUser() {
    return user;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:5,代码来源:TArticle.java

示例12: getOntologyType

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public OntologyType getOntologyType() {
    return ontologyType;
}
 
开发者ID:SnailFastGo,项目名称:ontology_setting,代码行数:5,代码来源:Ontology.java

示例13: setOntologyType

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public void setOntologyType(OntologyType ontologyType) {
    this.ontologyType = ontologyType;
}
 
开发者ID:SnailFastGo,项目名称:ontology_setting,代码行数:5,代码来源:Ontology.java

示例14: getSourceType

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public SourceType getSourceType() {
    return sourceType;
}
 
开发者ID:SnailFastGo,项目名称:ontology_setting,代码行数:5,代码来源:Source.java

示例15: setSourceType

import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public void setSourceType(SourceType sourceType) {
    this.sourceType = sourceType;
}
 
开发者ID:SnailFastGo,项目名称:ontology_setting,代码行数:5,代码来源:Source.java


注:本文中的com.fasterxml.jackson.annotation.JsonBackReference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。