use of com.fasterxml.jackson.databind.deser.impl.MethodProperty in project jackson-module-afterburner by FasterXML.
the class DeserializerModifier method findOptimizableProperties.
/*
/**********************************************************************
/* Internal methods
/**********************************************************************
*/
protected List<OptimizedSettableBeanProperty<?>> findOptimizableProperties(DeserializationConfig config, PropertyMutatorCollector collector, Iterator<SettableBeanProperty> propIterator) {
ArrayList<OptimizedSettableBeanProperty<?>> newProps = new ArrayList<OptimizedSettableBeanProperty<?>>();
// Ok, then, find any properties for which we could generate accessors
while (propIterator.hasNext()) {
SettableBeanProperty prop = propIterator.next();
AnnotatedMember member = prop.getMember();
Member jdkMember = member.getMember();
// if we ever support virtual properties, this would be null, so check, skip
if (jdkMember == null) {
continue;
}
// First: we can't access private fields or methods....
if (Modifier.isPrivate(jdkMember.getModifiers())) {
continue;
}
// 30-Jul-2012, tatu: [module-afterburner#6]: Needs to skip custom deserializers, if any.
if (prop.hasValueDeserializer()) {
if (!isDefaultDeserializer(prop.getValueDeserializer())) {
continue;
}
}
if (prop instanceof MethodProperty) {
// simple setter methods
Class<?> type = ((AnnotatedMethod) member).getRawParameterType(0);
if (type.isPrimitive()) {
if (type == Integer.TYPE) {
newProps.add(collector.addIntSetter(prop));
} else if (type == Long.TYPE) {
newProps.add(collector.addLongSetter(prop));
} else if (type == Boolean.TYPE) {
newProps.add(collector.addBooleanSetter(prop));
}
} else {
if (type == String.class) {
newProps.add(collector.addStringSetter(prop));
} else {
// any other Object types; we can at least call accessor
newProps.add(collector.addObjectSetter(prop));
}
}
} else if (prop instanceof FieldProperty) {
// be overwritable via Reflection)
if (Modifier.isFinal(prop.getMember().getMember().getModifiers())) {
continue;
}
Class<?> type = member.getRawType();
if (type.isPrimitive()) {
if (type == Integer.TYPE) {
newProps.add(collector.addIntField(prop));
} else if (type == Long.TYPE) {
newProps.add(collector.addLongField(prop));
} else if (type == Boolean.TYPE) {
newProps.add(collector.addBooleanField(prop));
}
} else {
if (type == String.class) {
newProps.add(collector.addStringField(prop));
} else {
// any other Object types; we can at least call accessor
newProps.add(collector.addObjectField(prop));
}
}
}
}
return newProps;
}
use of com.fasterxml.jackson.databind.deser.impl.MethodProperty in project beam by apache.
the class PipelineOptionsFactory method createBeanProperty.
private static BeanProperty createBeanProperty(Method method) {
AnnotationCollector ac = AnnotationCollector.emptyCollector();
for (Annotation ann : method.getAnnotations()) {
ac = ac.addOrOverride(ann);
}
AnnotatedMethod annotatedMethod = new AnnotatedMethod(new TypeResolutionContext.Basic(MAPPER.getTypeFactory(), TypeBindings.emptyBindings()), method, ac.asAnnotationMap(), null);
BeanPropertyDefinition propDef = SimpleBeanPropertyDefinition.construct(MAPPER.getDeserializationConfig(), annotatedMethod);
JavaType type = MAPPER.constructType(method.getGenericReturnType());
try {
return new MethodProperty(propDef, type, MAPPER.getDeserializationConfig().findTypeDeserializer(type), annotatedMethod.getAllAnnotations(), annotatedMethod);
} catch (JsonMappingException e) {
throw new RuntimeException(e);
}
}
Aggregations