for (BeanPropertyDefinition propDef : beanDesc.findProperties()) { Iterator<AnnotatedParameter> it = propDef.getConstructorParameters(); while (it.hasNext()) {
.findProperties(); for (BeanPropertyDefinition beanDef : beanDefs) { final AnnotatedField field = beanDef.getField();
final List<BeanPropertyDefinition> properties = introspection.findProperties();
throws JsonMappingException List<BeanPropertyDefinition> properties = beanDesc.findProperties(); final SerializationConfig config = prov.getConfig();
final List<BeanPropertyDefinition> properties = beanDesc.findProperties();
for (BeanPropertyDefinition def : beanDesc.findProperties()) { final String name = def.getName(); if (name != null && name.equals(propertyName)) {
/** * Mostly for kotlin null safe operator and immutable properties. * * @param type Target type. * @param model Model. * @return Input model. */ private Model doModel(Type type, Model model) { Map<String, Property> properties = model.getProperties(); if (properties != null) { BeanDescription desc = Json.mapper().getSerializationConfig() .introspect(Json.mapper().constructType(type)); for (BeanPropertyDefinition beanProperty : desc.findProperties()) { Property property = properties.get(beanProperty.getName()); if (property != null) { property.setRequired(beanProperty.isRequired()); } } } return model; }
List<BeanPropertyDefinition> properties = beanDesc.findProperties(); for (BeanPropertyDefinition prop : properties) { if (StringUtils.isNotBlank(prop.getInternalName()) && prop.getInternalName().equals(propDef.getInternalName())) {
Map<String, Schema> modelProps = new LinkedHashMap<String, Schema>(); List<BeanPropertyDefinition> properties = beanDesc.findProperties(); List<String> ignoredProps = getIgnoredProperties(beanDesc); properties.removeIf(p -> ignoredProps.contains(p.getName())); if (member == null) { final BeanDescription deserBeanDesc = _mapper.getDeserializationConfig().introspect(type); List<BeanPropertyDefinition> deserProperties = deserBeanDesc.findProperties(); for (BeanPropertyDefinition prop : deserProperties) { if (StringUtils.isNotBlank(prop.getInternalName()) && prop.getInternalName().equals(propDef.getInternalName())) {
/** * Returns the {@link PersistentProperty} for the property with the given final name (the name that it will be * rendered under eventually). * * @param finalName the output name the property will be rendered under. * @param entity the {@link PersistentEntity} to find the property on. * @param description the Jackson {@link BeanDescription}. * @return */ private Optional<? extends PersistentProperty<?>> findProperty(String finalName, PersistentEntity<?, ? extends PersistentProperty<?>> entity, BeanDescription description) { return description.findProperties().stream()// .filter(it -> it.getName().equals(finalName))// .findFirst().map(it -> entity.getPersistentProperty(it.getInternalName())); } }
beanDesc, builder, beanDesc.findProperties(), ignored);
/** * Creates a new {@link MappedProperties} instance for the given {@link PersistentEntity} and {@link BeanDescription}. * * @param entity must not be {@literal null}. * @param description must not be {@literal null}. */ private MappedProperties(PersistentEntity<?, ? extends PersistentProperty<?>> entity, BeanDescription description) { Assert.notNull(entity, "Entity must not be null!"); Assert.notNull(description, "BeanDescription must not be null!"); this.propertyToFieldName = new HashMap<PersistentProperty<?>, BeanPropertyDefinition>(); this.fieldNameToProperty = new HashMap<String, PersistentProperty<?>>(); this.unmappedProperties = new HashSet<BeanPropertyDefinition>(); for (BeanPropertyDefinition property : description.findProperties()) { if (description.getIgnoredPropertyNames().contains(property.getName())) { continue; } Optional<? extends PersistentProperty<?>> persistentProperty = // Optional.ofNullable(entity.getPersistentProperty(property.getInternalName())); persistentProperty.ifPresent(it -> { propertyToFieldName.put(it, property); fieldNameToProperty.put(property.getName(), it); }); if (!persistentProperty.isPresent()) { unmappedProperties.add(property); } } }
private List<BeanPropertyDefinition> getMappedProperties(PersistentEntity<?, ?> entity) { List<BeanPropertyDefinition> properties = getBeanDescription(entity.getType()).findProperties(); List<BeanPropertyDefinition> withInternalName = new ArrayList<BeanPropertyDefinition>(properties.size()); for (BeanPropertyDefinition property : properties) { Optionals.ifAllPresent(findAnnotatedMember(property), // Optional.ofNullable(entity.getPersistentProperty(property.getInternalName())), // (member, prop) -> withInternalName.add(property)); } return withInternalName; }
/** * Creates a new {@link JacksonMetadata} instance for the given {@link ObjectMapper} and type. * * @param mapper must not be {@literal null}. * @param type must not be {@literal null}. */ public JacksonMetadata(ObjectMapper mapper, Class<?> type) { Assert.notNull(mapper, "ObjectMapper must not be null!"); Assert.notNull(type, "Type must not be null!"); this.mapper = mapper; SerializationConfig serializationConfig = mapper.getSerializationConfig(); JavaType javaType = serializationConfig.constructType(type); BeanDescription description = serializationConfig.introspect(javaType); this.definitions = description.findProperties(); this.isValue = description.findJsonValueMethod() != null; DeserializationConfig deserializationConfig = mapper.getDeserializationConfig(); JavaType deserializationType = deserializationConfig.constructType(type); this.deserializationDefinitions = deserializationConfig.introspect(deserializationType).findProperties(); }
public void init(SerializationConfig serializationConfig, JavaType javaType) { this.javaType = javaType; BeanDescription beanDescription = serializationConfig.introspect(javaType); for (BeanPropertyDefinition propertyDefinition : beanDescription.findProperties()) { PropertyDescriptor propertyDescriptor = new PropertyDescriptor(); propertyDescriptor.setName(propertyDefinition.getName()); propertyDescriptor.setJavaType(propertyDefinition.getPrimaryType()); try { propertyDescriptor.setGetter(initGetter(propertyDefinition)); } catch (Throwable e) { LOGGER.error("failed to init getter for field {}:{}", javaType.getRawClass().getName(), propertyDefinition.getName(), e); } try { propertyDescriptor.setSetter(initSetter(propertyDefinition)); } catch (Throwable e) { LOGGER.error("failed to init setter for field {}:{}", javaType.getRawClass().getName(), propertyDefinition.getName(), e); } propertyDescriptors.put(propertyDefinition.getName(), propertyDescriptor); } }
JavaType userType = mapper.getTypeFactory().constructType(User.class); BeanDescription introspection = mapper.getSerializationConfig().introspect(userType); List<BeanPropertyDefinition> properties = introspection.findProperties(); // do some processing over properties...
public static Optional<BeanPropertyDefinition> jacksonPropertyWithSameInternalName(BeanDescription beanDescription, BeanPropertyDefinition propertyDefinition) { return FluentIterable.from(beanDescription.findProperties()) .firstMatch(withSameInternalName(propertyDefinition)); }
public static Optional<BeanPropertyDefinition> jacksonPropertyWithSameInternalName(BeanDescription beanDescription, BeanPropertyDefinition propertyDefinition) { return FluentIterable.from(beanDescription.findProperties()) .firstMatch(withSameInternalName(propertyDefinition)); }
public static Optional<BeanPropertyDefinition> jacksonPropertyWithSameInternalName(BeanDescription beanDescription, BeanPropertyDefinition propertyDefinition) { return FluentIterable.from(beanDescription.findProperties()) .firstMatch(withSameInternalName(propertyDefinition)); }
@Override public Set<InputField> getInputFields(InputFieldBuilderParams params) { JavaType javaType = objectMapper.getTypeFactory().constructType(params.getType().getType()); BeanDescription desc = objectMapper.getDeserializationConfig().introspect(javaType); return desc.findProperties().stream() .filter(BeanPropertyDefinition::couldDeserialize) .flatMap(prop -> toInputField(params.getType(), prop, params.getEnvironment())) .collect(Collectors.toSet()); }