本文整理汇总了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;
}
示例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;
});
}
示例3: getMeeting
import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@Id
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "meeting_id")
@JsonBackReference
public Meeting getMeeting() {
return meeting;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例11: getUser
import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public TUser getUser() {
return user;
}
示例12: getOntologyType
import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public OntologyType getOntologyType() {
return ontologyType;
}
示例13: setOntologyType
import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public void setOntologyType(OntologyType ontologyType) {
this.ontologyType = ontologyType;
}
示例14: getSourceType
import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public SourceType getSourceType() {
return sourceType;
}
示例15: setSourceType
import com.fasterxml.jackson.annotation.JsonBackReference; //导入依赖的package包/类
@JsonBackReference
public void setSourceType(SourceType sourceType) {
this.sourceType = sourceType;
}