com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition

Here are the examples of the java api class com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition taken from open source projects.

1. JacksonObjectIdUpdater#setObjectId()

Project: jongo
File: JacksonObjectIdUpdater.java
public void setObjectId(Object target, ObjectId id) {
    for (BeanPropertyDefinition def : beanDescription(target.getClass()).findProperties()) {
        if (isIdProperty(def)) {
            AnnotatedMember accessor = def.getAccessor();
            accessor.fixAccess();
            if (accessor.getValue(target) != null) {
                throw new IllegalArgumentException("Unable to set objectid on class: " + target.getClass());
            }
            AnnotatedMember field = def.getField();
            field.fixAccess();
            Class<?> type = field.getRawType();
            if (ObjectId.class.isAssignableFrom(type)) {
                field.setValue(target, id);
            } else if (type.equals(String.class) && isObjectId(def)) {
                field.setValue(target, id.toString());
            }
            return;
        }
    }
}

2. JacksonObjectIdUpdater#getId()

Project: jongo
File: JacksonObjectIdUpdater.java
public Object getId(Object pojo) {
    BasicBeanDescription beanDescription = beanDescription(pojo.getClass());
    for (BeanPropertyDefinition def : beanDescription.findProperties()) {
        if (isIdProperty(def)) {
            AnnotatedMember accessor = def.getAccessor();
            accessor.fixAccess();
            Object id = accessor.getValue(pojo);
            if (id instanceof String && isObjectId(def)) {
                return new ObjectId(id.toString());
            } else {
                return id;
            }
        }
    }
    return null;
}

3. EktorpBeanDeserializerModifier#collectFields()

Project: Ektorp
File: EktorpBeanDeserializerModifier.java
private List<ConstructibleAnnotatedCollection> collectFields(final DeserializationConfig config, final BeanDescription desc) {
    final List<ConstructibleAnnotatedCollection> fields = new ArrayList<ConstructibleAnnotatedCollection>();
    final Map<String, AnnotatedMethod> setters = new LinkedHashMap<String, AnnotatedMethod>();
    List<BeanPropertyDefinition> properties = desc.findProperties();
    for (BeanPropertyDefinition beanPropertyDefinition : properties) {
        setters.put(beanPropertyDefinition.getInternalName(), beanPropertyDefinition.getSetter());
    }
    ReflectionUtils.eachField(desc.getType().getRawClass(), new Predicate<Field>() {

        @Override
        public boolean apply(Field input) {
            if (ReflectionUtils.hasAnnotation(input, DocumentReferences.class)) {
                ConstructibleAnnotatedCollection c = collectBackrefField(config, desc, setters, input);
                if (c != null) {
                    fields.add(c);
                }
            }
            return false;
        }
    });
    return fields;
}

4. JsonConfigurator#verifyClazzIsConfigurable()

Project: druid
File: JsonConfigurator.java
private <T> void verifyClazzIsConfigurable(Class<T> clazz) {
    final List<BeanPropertyDefinition> beanDefs = jsonMapper.getSerializationConfig().introspect(jsonMapper.constructType(clazz)).findProperties();
    for (BeanPropertyDefinition beanDef : beanDefs) {
        final AnnotatedField field = beanDef.getField();
        if (field == null || !field.hasAnnotation(JsonProperty.class)) {
            throw new ProvisionException(String.format("JsonConfigurator requires Jackson-annotated Config objects to have field annotations. %s doesn't", clazz));
        }
    }
}

5. DynamicFilePropertyOmittingSerializerModifier#findProperty()

Project: light-admin
File: DynamicFilePropertyOmittingSerializerModifier.java
private PersistentProperty<?> findProperty(String finalName, PersistentEntity<?, ?> entity, BeanDescription description) {
    for (BeanPropertyDefinition definition : description.findProperties()) {
        if (definition.getName().equals(finalName)) {
            return entity.getPersistentProperty(definition.getInternalName());
        }
    }
    return null;
}

6. JacksonObjectIdUpdater#mustGenerateObjectId()

Project: jongo
File: JacksonObjectIdUpdater.java
public boolean mustGenerateObjectId(Object pojo) {
    for (BeanPropertyDefinition def : beanDescription(pojo.getClass()).findProperties()) {
        if (isIdProperty(def)) {
            AnnotatedMember accessor = def.getAccessor();
            accessor.fixAccess();
            return isObjectId(def) && accessor.getValue(pojo) == null;
        }
    }
    return false;
}