本文整理匯總了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;
}