/** * Pass-through constructor that may be used by sub-classes that * want full control over implementation. */ protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Value inclusion, Class<?>[] includeInViews) { super(propDef, propDef.getPrimaryMember(), contextAnnotations, declaredType, ser, typeSer, serType, _suppressNulls(inclusion), _suppressableValue(inclusion), includeInViews); }
final String name = def.getName(); if (name != null && name.equals(propertyName)) { final AnnotatedMember propMember = def.getPrimaryMember(); final JavaType propType = propMember.getType(); if (PrimitiveType.fromType(propType) != null) {
Annotation[] annotations = null; AnnotatedMember member = propDef.getPrimaryMember(); if (member == null) { final BeanDescription deserBeanDesc = _mapper.getDeserializationConfig().introspect(type); for (BeanPropertyDefinition prop : deserProperties) { if (StringUtils.isNotBlank(prop.getInternalName()) && prop.getInternalName().equals(propDef.getInternalName())) { member = prop.getPrimaryMember(); break; if(propDef.getPrimaryMember() != null) { final JsonProperty jsonPropertyAnn = propDef.getPrimaryMember().getAnnotation(JsonProperty.class); if (jsonPropertyAnn == null || !jsonPropertyAnn.value().equals(propName)) { if (member != null) {
private static String[] getCodes(BeanPropertyDefinition property) { Assert.notNull(property, "BeanPropertyDefinition must not be null!"); Class<?> owner = property.getPrimaryMember().getDeclaringClass(); String propertyTitle = property.getInternalName().concat("._title"); String localName = owner.getSimpleName().concat(".").concat(propertyTitle); String fullName = owner.getName().concat(".").concat(propertyTitle); return new String[] { fullName, localName, propertyTitle }; } }
private static Optional<AnnotatedMember> findAnnotatedMember(BeanPropertyDefinition property) { if (property.getPrimaryMember() != null) { return Optional.of(property.getPrimaryMember()); } if (property.getGetter() != null) { return Optional.of(property.getGetter()); } if (property.getSetter() != null) { return Optional.of(property.getSetter()); } return Optional.empty(); }
@SuppressWarnings("rawtypes") public TypeInformation<?> getPropertyType() { return property.map(it -> (TypeInformation) it.getTypeInformation()) .orElseGet(() -> ClassTypeInformation.from(definition.getPrimaryMember().getRawType())); }
/** * Returns the fallback {@link ResourceDescription} to be used for the given {@link BeanPropertyDefinition}. * * @param ownerMetadata must not be {@literal null}. * @param definition must not be {@literal null}. * @return */ public ResourceDescription getFallbackDescription(ResourceMetadata ownerMetadata, BeanPropertyDefinition definition) { Assert.notNull(ownerMetadata, "Owner's resource metadata must not be null!"); Assert.notNull(definition, "BeanPropertyDefinition must not be null!"); AnnotatedMember member = definition.getPrimaryMember(); Description description = member.getAnnotation(Description.class); ResourceDescription fallback = TypedResourceDescription.defaultFor(ownerMetadata.getItemResourceRel(), definition.getInternalName(), definition.getPrimaryMember().getRawType()); return description == null ? fallback : new AnnotationBasedResourceDescription(description, fallback); }
AnnotatedMember primaryMember = definition.getPrimaryMember();
private static String[] getCodes(BeanPropertyDefinition property) { Assert.notNull(property, "BeanPropertyDefinition must not be null!"); Class<?> owner = property.getPrimaryMember().getDeclaringClass(); String propertyTitle = property.getInternalName().concat("._title"); String localName = owner.getSimpleName().concat(".").concat(propertyTitle); String fullName = owner.getName().concat(".").concat(propertyTitle); return new String[] { fullName, localName, propertyTitle }; } }
private static Optional<AnnotatedMember> findAnnotatedMember(BeanPropertyDefinition property) { if (property.getPrimaryMember() != null) { return Optional.of(property.getPrimaryMember()); } if (property.getGetter() != null) { return Optional.of(property.getGetter()); } if (property.getSetter() != null) { return Optional.of(property.getSetter()); } return Optional.empty(); }
/** * Pass-through constructor that may be used by sub-classes that * want full control over implementation. */ protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Include inclusion) { super(propDef, propDef.getPrimaryMember(), contextAnnotations, declaredType, ser, typeSer, serType, _suppressNulls(inclusion), _suppressableValue(inclusion)); }
/** * Pass-through constructor that may be used by sub-classes that * want full control over implementation. */ protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Value inclusion) { super(propDef, propDef.getPrimaryMember(), contextAnnotations, declaredType, ser, typeSer, serType, _suppressNulls(inclusion), _suppressableValue(inclusion)); }
@SuppressWarnings("rawtypes") public TypeInformation<?> getPropertyType() { return property.map(it -> (TypeInformation) it.getTypeInformation()) .orElseGet(() -> ClassTypeInformation.from(definition.getPrimaryMember().getRawType())); }
/** * Pass-through constructor that may be used by sub-classes that * want full control over implementation. */ protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Include inclusion) { super(propDef, propDef.getPrimaryMember(), contextAnnotations, declaredType, ser, typeSer, serType, _suppressNulls(inclusion), _suppressableValue(inclusion)); }
/** * Pass-through constructor that may be used by sub-classes that * want full control over implementation. */ protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, JsonInclude.Value inclusion, Class<?>[] includeInViews) { super(propDef, propDef.getPrimaryMember(), contextAnnotations, declaredType, ser, typeSer, serType, _suppressNulls(inclusion), _suppressableValue(inclusion), includeInViews); }
@Override public List<ModelProperty> propertiesFor(ResolvedType type, ModelContext givenContext) { List<ModelProperty> serializationCandidates = newArrayList(); BeanDescription beanDescription = beanDescription(type, givenContext); Map<String, BeanPropertyDefinition> propertyLookup = uniqueIndex(beanDescription.findProperties(), BeanPropertyDefinitions.beanPropertyByInternalName()); for (Map.Entry<String, BeanPropertyDefinition> each : propertyLookup.entrySet()) { BeanPropertyDefinition propertyDefinition = each.getValue(); Optional<BeanPropertyDefinition> jacksonProperty = jacksonPropertyWithSameInternalName(beanDescription, propertyDefinition); AnnotatedMember member = propertyDefinition.getPrimaryMember(); Optional<ResolvedMethod> accessor = findAccessorMethod(type, each.getKey(), member); if (accessor.isPresent()) { serializationCandidates .addAll(addCandidateProperties(member, accessor.get(), jacksonProperty, givenContext)); } } return serializationCandidates; }
/** * Returns the fallback {@link ResourceDescription} to be used for the given {@link BeanPropertyDefinition}. * * @param ownerMetadata must not be {@literal null}. * @param definition must not be {@literal null}. * @return */ public ResourceDescription getFallbackDescription(ResourceMetadata ownerMetadata, BeanPropertyDefinition definition) { Assert.notNull(ownerMetadata, "Owner's resource metadata must not be null!"); Assert.notNull(definition, "BeanPropertyDefinition must not be null!"); AnnotatedMember member = definition.getPrimaryMember(); Description description = member.getAnnotation(Description.class); ResourceDescription fallback = TypedResourceDescription.defaultFor(ownerMetadata.getItemResourceRel(), definition.getInternalName(), definition.getPrimaryMember().getRawType()); return description == null ? fallback : new AnnotationBasedResourceDescription(description, fallback); }
@Override public Iterable<? extends ModelProperty> propertiesForSerialization(ResolvedType resolvedType) { List<ModelProperty> serializationCandidates = newArrayList(); SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); BeanDescription beanDescription = serializationConfig.introspect(TypeFactory.defaultInstance() .constructType(resolvedType.getErasedType())); Map<String, BeanPropertyDefinition> propertyLookup = Maps.uniqueIndex(beanDescription.findProperties(), BeanPropertyDefinitions.beanPropertyByInternalName()); for (ResolvedField childField : fieldProvider.in(resolvedType)) { if (propertyLookup.containsKey(childField.getName())) { BeanPropertyDefinition propertyDefinition = propertyLookup.get(childField.getName()); Optional<BeanPropertyDefinition> jacksonProperty = jacksonPropertyWithSameInternalName(beanDescription, propertyDefinition); AnnotatedMember member = propertyDefinition.getPrimaryMember(); serializationCandidates.addAll(newArrayList(addSerializationCandidates(member, childField, jacksonProperty))); } } return serializationCandidates; }
@Override public Iterable<? extends ModelProperty> propertiesForDeserialization(ResolvedType resolvedType) { List<ModelProperty> serializationCandidates = newArrayList(); DeserializationConfig serializationConfig = objectMapper.getDeserializationConfig(); BeanDescription beanDescription = serializationConfig.introspect(TypeFactory.defaultInstance() .constructType(resolvedType.getErasedType())); Map<String, BeanPropertyDefinition> propertyLookup = uniqueIndex(beanDescription.findProperties(), BeanPropertyDefinitions.beanPropertyByInternalName()); for (ResolvedField childField : fieldProvider.in(resolvedType)) { if (propertyLookup.containsKey(childField.getName())) { BeanPropertyDefinition propertyDefinition = propertyLookup.get(childField.getName()); Optional<BeanPropertyDefinition> jacksonProperty = jacksonPropertyWithSameInternalName(beanDescription, propertyDefinition); AnnotatedMember member = propertyDefinition.getPrimaryMember(); serializationCandidates.addAll(newArrayList(addDeserializationCandidates(member, childField, jacksonProperty))); } } return serializationCandidates; }
@Override public Iterable<? extends ModelProperty> propertiesForSerialization(ResolvedType resolvedType) { List<ModelProperty> serializationCandidates = newArrayList(); SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); BeanDescription beanDescription = serializationConfig.introspect(TypeFactory.defaultInstance() .constructType(resolvedType.getErasedType())); Map<String, BeanPropertyDefinition> propertyLookup = uniqueIndex(beanDescription.findProperties(), BeanPropertyDefinitions.beanPropertyByInternalName()); for (ResolvedMethod childProperty : accessors.in(resolvedType)) { if (propertyLookup.containsKey(propertyName(childProperty.getName()))) { BeanPropertyDefinition propertyDefinition = propertyLookup.get(propertyName(childProperty.getName())); Optional<BeanPropertyDefinition> jacksonProperty = jacksonPropertyWithSameInternalName(beanDescription, propertyDefinition); AnnotatedMember member = propertyDefinition.getPrimaryMember(); if (accessorMemberIs(childProperty, methodName(member))) { serializationCandidates.add(beanModelProperty(childProperty, jacksonProperty, true)); } } } return serializationCandidates; }