Java 类com.fasterxml.jackson.annotation.JsonBackReference 实例源码

项目:javadoc2swagger    文件:DefinitionParser.java   
/**
 * 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;
}
项目: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(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;
  });
}
项目:leanbean    文件:Vote.java   
@Id
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "meeting_id")
@JsonBackReference
public Meeting getMeeting() {
  return meeting;
}
项目:QuizUpWinner    文件:JacksonAnnotationIntrospector.java   
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;
}
项目:QuizUpWinner    文件:JacksonAnnotationIntrospector.java   
public String findDeserializationName(AnnotatedMethod paramAnnotatedMethod)
{
  JsonSetter localJsonSetter = (JsonSetter)paramAnnotatedMethod.getAnnotation(JsonSetter.class);
  if (localJsonSetter != null)
    return localJsonSetter.value();
  JsonProperty localJsonProperty = (JsonProperty)paramAnnotatedMethod.getAnnotation(JsonProperty.class);
  if (localJsonProperty != null)
    return localJsonProperty.value();
  if ((paramAnnotatedMethod.hasAnnotation(JsonDeserialize.class)) || (paramAnnotatedMethod.hasAnnotation(JsonView.class)) || (paramAnnotatedMethod.hasAnnotation(JsonBackReference.class)) || (paramAnnotatedMethod.hasAnnotation(JsonManagedReference.class)))
    return "";
  return null;
}
项目:QuizUpWinner    文件:JacksonAnnotationIntrospector.java   
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;
}
项目:minnal    文件:BiDirectionalObjectResolver.java   
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;
}
项目:minnal    文件:BiDirectionalCollectionResolver.java   
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;
}
项目:minnal    文件:ExcludeAnnotationsConvertorTest.java   
@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);
}
项目:GitHub    文件:Order.java   
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="customerNumber", nullable=false)
@JsonBackReference("order-customer")
public Customer getCustomer() {
    return this.customer;
}
项目:GitHub    文件:OrderDetail.java   
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="orderNumber", nullable=false, insertable=false, updatable=false)
@JsonBackReference("orderdetail-order")
public Order getOrder() {
    return this.order;
}
项目:GitHub    文件:OrderDetail.java   
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="productCode", nullable=false, insertable=false, updatable=false)
@JsonBackReference("order-product")
public Product getProduct() {
    return this.product;
}
项目:asura    文件:TArticle.java   
@JsonBackReference
public TUser getUser() {
    return user;
}
项目:ontology_setting    文件:Ontology.java   
@JsonBackReference
public OntologyType getOntologyType() {
    return ontologyType;
}
项目:ontology_setting    文件:Ontology.java   
@JsonBackReference
public void setOntologyType(OntologyType ontologyType) {
    this.ontologyType = ontologyType;
}
项目:ontology_setting    文件:Source.java   
@JsonBackReference
public SourceType getSourceType() {
    return sourceType;
}
项目:ontology_setting    文件:Source.java   
@JsonBackReference
public void setSourceType(SourceType sourceType) {
    this.sourceType = sourceType;
}
项目:ontology_setting    文件:Source.java   
@JsonBackReference
public UpdateLevel getUpdateLevel() {
    return updateLevel;
}
项目:ontology_setting    文件:Source.java   
@JsonBackReference
public void setUpdateLevel(UpdateLevel updateLevel) {
    this.updateLevel = updateLevel;
}
项目:ontology_setting    文件:OntologyProperty.java   
@JsonBackReference
public Ontology getOntology() {
    return ontology;
}
项目:ontology_setting    文件:OntologyProperty.java   
@JsonBackReference
public void setOntology(Ontology ontology) {
    this.ontology = ontology;
}
项目:Spring-MVC-Blueprints    文件:PaymentAp.java   
@XmlTransient
   @JsonBackReference("paymentAp")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "paymentAp")
public Set<Invoice> getInvoices() {
    return this.invoices;
}
项目:Spring-MVC-Blueprints    文件:PaymentAp.java   
@XmlTransient
   @JsonBackReference("paymentAp")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "paymentAp")
public Set<Invoice> getInvoices() {
    return this.invoices;
}
项目:Spring-MVC-Blueprints    文件:StationDetail.java   
@JsonBackReference("trips-data")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "stationDetail")
public Set<Trip> getTrips() {
    return this.trips;
}
项目:Spring-MVC-Blueprints    文件:CustomerInfo.java   
@JsonBackReference("customer-data")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "customerInfo")
public Set<BookedTrip> getBookedTrips() {
    return this.bookedTrips;
}
项目:Spring-MVC-Blueprints    文件:Trip.java   
@JsonBackReference("trips-data")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "stationId", nullable = false)
public StationDetail getStationDetail() {
    return this.stationDetail;
}
项目:Spring-MVC-Blueprints    文件:Trip.java   
@JsonBackReference("booked-data")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "trip")
public Set<BookedTrip> getBookedTrips() {
    return this.bookedTrips;
}
项目:melon    文件:Menu.java   
@JsonBackReference
@NotNull
public Menu getParent() {
    return parent;
}
项目:Shop-for-JavaWeb    文件:ActUtils.java   
@SuppressWarnings({ "unused" })
public static Map<String, Object> getMobileEntity(Object entity,String spiltType){
    if(spiltType==null){
        spiltType="@";
    }
    Map<String, Object> map = Maps.newHashMap();

    List<String> field = Lists.newArrayList();
    List<String> value = Lists.newArrayList();
    List<String> chinesName =Lists.newArrayList();

    try{
        for (Method m : entity.getClass().getMethods()){
            if (m.getAnnotation(JsonIgnore.class) == null && m.getAnnotation(JsonBackReference.class) == null && m.getName().startsWith("get")){
                if (m.isAnnotationPresent(FieldName.class)) {
                    Annotation p = m.getAnnotation(FieldName.class);
                    FieldName fieldName=(FieldName) p;
                    chinesName.add(fieldName.value());
                }else{
                    chinesName.add("");
                }
                if (m.getName().equals("getAct")){
                    Object act = m.invoke(entity, new Object[]{});
                    Method actMet = act.getClass().getMethod("getTaskId");
                    map.put("taskId", ObjectUtils.toString(m.invoke(act, new Object[]{}), ""));
                }else{
                    field.add(StringUtils.uncapitalize(m.getName().substring(3)));
                    value.add(ObjectUtils.toString(m.invoke(entity, new Object[]{}), ""));
                }
            }
        }
    }catch (Exception e) {
        e.printStackTrace();
    }

    map.put("beanTitles", StringUtils.join(field, spiltType));
    map.put("beanInfos", StringUtils.join(value, spiltType));
    map.put("chineseNames", StringUtils.join(chinesName, spiltType));

    return map;
}
项目:Shop-for-JavaWeb    文件:Menu.java   
@JsonBackReference
@NotNull
public Menu getParent() {
    return parent;
}
项目:flowable-engine    文件:Lane.java   
@JsonBackReference
public Process getParentProcess() {
    return parentProcess;
}
项目:code    文件:OObject.java   
@JsonBackReference("objectParent")
public IDomain getParent() {
    return parent;
}
项目:code    文件:ODomain.java   
@JsonBackReference("domainParents")
public Set<IObject> getParents() {
    return parents;
}
项目:Purifinity    文件:AbstractUniversalSyntaxTreeNode.java   
@Override
@JsonBackReference
public final UniversalSyntaxTree getParent() {
    return parent;
}
项目:Purifinity    文件:AnalysisRunFileTree.java   
@Override
   @JsonBackReference
   public AnalysisRunFileTree getParent() {
return parent;
   }
项目:Purifinity    文件:AnalysisRunFileTree.java   
@JsonBackReference
   public void setParent(AnalysisRunFileTree parent) {
this.parent = parent;
   }
项目:eMonocot    文件:Description.java   
/**
 *
 * @return Get the taxon that this content is about.
 */
@ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference("descriptions-taxon")
public Taxon getTaxon() {
    return taxon;
}
项目:eMonocot    文件:MeasurementOrFact.java   
@ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference("measurementsOrFacts-taxon")
public Taxon getTaxon() {
    return taxon;
}
项目:eMonocot    文件:MeasurementOrFact.java   
@JsonBackReference("measurementsOrFacts-taxon")
public void setTaxon(Taxon taxon) {
    this.taxon = taxon;
}
项目:eMonocot    文件:Identifier.java   
/**
 * The taxon (page) this identifier is related to.
 *
 * @return the taxon this image is of
 */
@ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference("identifier-taxon")
public Taxon getTaxon() {
    return taxon;
}