/** * 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; }
/** * 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 @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "meeting_id") @JsonBackReference public Meeting getMeeting() { return meeting; }
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; }
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; }
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; }
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; }
@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); }
@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="customerNumber", nullable=false) @JsonBackReference("order-customer") public Customer getCustomer() { return this.customer; }
@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="orderNumber", nullable=false, insertable=false, updatable=false) @JsonBackReference("orderdetail-order") public Order getOrder() { return this.order; }
@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="productCode", nullable=false, insertable=false, updatable=false) @JsonBackReference("order-product") public Product getProduct() { return this.product; }
@JsonBackReference public TUser getUser() { return user; }
@JsonBackReference public OntologyType getOntologyType() { return ontologyType; }
@JsonBackReference public void setOntologyType(OntologyType ontologyType) { this.ontologyType = ontologyType; }
@JsonBackReference public SourceType getSourceType() { return sourceType; }
@JsonBackReference public void setSourceType(SourceType sourceType) { this.sourceType = sourceType; }
@JsonBackReference public UpdateLevel getUpdateLevel() { return updateLevel; }
@JsonBackReference public void setUpdateLevel(UpdateLevel updateLevel) { this.updateLevel = updateLevel; }
@JsonBackReference public Ontology getOntology() { return ontology; }
@JsonBackReference public void setOntology(Ontology ontology) { this.ontology = ontology; }
@XmlTransient @JsonBackReference("paymentAp") @OneToMany(fetch = FetchType.LAZY, mappedBy = "paymentAp") public Set<Invoice> getInvoices() { return this.invoices; }
@JsonBackReference("trips-data") @OneToMany(fetch = FetchType.LAZY, mappedBy = "stationDetail") public Set<Trip> getTrips() { return this.trips; }
@JsonBackReference("customer-data") @OneToMany(fetch = FetchType.LAZY, mappedBy = "customerInfo") public Set<BookedTrip> getBookedTrips() { return this.bookedTrips; }
@JsonBackReference("trips-data") @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "stationId", nullable = false) public StationDetail getStationDetail() { return this.stationDetail; }
@JsonBackReference("booked-data") @OneToMany(fetch = FetchType.LAZY, mappedBy = "trip") public Set<BookedTrip> getBookedTrips() { return this.bookedTrips; }
@JsonBackReference @NotNull public Menu getParent() { return parent; }
@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; }
@JsonBackReference public Process getParentProcess() { return parentProcess; }
@JsonBackReference("objectParent") public IDomain getParent() { return parent; }
@JsonBackReference("domainParents") public Set<IObject> getParents() { return parents; }
@Override @JsonBackReference public final UniversalSyntaxTree getParent() { return parent; }
@Override @JsonBackReference public AnalysisRunFileTree getParent() { return parent; }
@JsonBackReference public void setParent(AnalysisRunFileTree parent) { this.parent = parent; }
/** * * @return Get the taxon that this content is about. */ @ManyToOne(fetch = FetchType.LAZY) @JsonBackReference("descriptions-taxon") public Taxon getTaxon() { return taxon; }
@ManyToOne(fetch = FetchType.LAZY) @JsonBackReference("measurementsOrFacts-taxon") public Taxon getTaxon() { return taxon; }
@JsonBackReference("measurementsOrFacts-taxon") public void setTaxon(Taxon taxon) { this.taxon = taxon; }
/** * 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; }