Example usage for com.fasterxml.jackson.databind DeserializationConfig introspect

List of usage examples for com.fasterxml.jackson.databind DeserializationConfig introspect

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind DeserializationConfig introspect.

Prototype

public <T extends BeanDescription> T introspect(JavaType paramJavaType) 

Source Link

Usage

From source file:org.springframework.data.rest.webmvc.json.JacksonMetadata.java

/**
 * Creates a new {@link JacksonMetadata} instance for the given {@link ObjectMapper} and type.
 * //from w  ww .  j  a va2  s  .c o  m
 * @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();
}

From source file:org.midonet.cluster.rest_api.serialization.MidonetObjectMapper.java

static JsonError getError(DeserializationConfig config, JavaType valueType, String fieldName) {
    try {//from w  w  w  .j  a v  a 2s.c  o m
        BasicBeanDescription beanDesc = config.introspect(valueType);
        for (BeanPropertyDefinition property : beanDesc.findProperties()) {
            if (property.getName().equals(fieldName) && null != property.getField()
                    && null != property.getField().getAnnotated()) {
                return property.getField().getAnnotated().getAnnotation(JsonError.class);
            }
        }
        return null;
    } catch (Exception e) {
        return null;
    }
}