use of com.fasterxml.jackson.databind.introspect.AnnotatedClass in project jackson-databind by FasterXML.
the class RootNameLookup method findRootName.
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) {
ClassKey key = new ClassKey(rootType);
PropertyName name = _rootNames.get(key);
if (name != null) {
return name;
}
BeanDescription beanDesc = config.introspectClassAnnotations(rootType);
AnnotationIntrospector intr = config.getAnnotationIntrospector();
AnnotatedClass ac = beanDesc.getClassInfo();
name = intr.findRootName(ac);
// No answer so far? Let's just default to using simple class name
if (name == null || !name.hasSimpleName()) {
// Should we strip out enclosing class tho? For now, nope:
name = PropertyName.construct(rootType.getSimpleName());
}
_rootNames.put(key, name);
return name;
}
use of com.fasterxml.jackson.databind.introspect.AnnotatedClass in project crnk-framework by crnk-project.
the class JacksonResourceFieldInformationProvider method getName.
protected Optional<String> getName(Method method) {
ObjectMapper objectMapper = context.getObjectMapper();
SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
String name = ClassUtils.getGetterFieldName(method);
Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);
int paramsLength = method.getParameterAnnotations().length;
AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
for (int i = 0; i < paramsLength; i++) {
AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
paramAnnotations[i] = parameterAnnotationMap;
}
AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name));
}
return Optional.empty();
}
Aggregations