Example usage for com.fasterxml.jackson.databind JavaType getRawClass

List of usage examples for com.fasterxml.jackson.databind JavaType getRawClass

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JavaType getRawClass.

Prototype

public final Class<?> getRawClass() 

Source Link

Usage

From source file:io.swagger.test.SerializableParamExtractionTest.java

@org.junit.Test
public void getStringArrayParameterClassTest() throws Exception {
    JavaType jt = utils
            .getTypeFromParameter(new QueryParameter().property(new ArrayProperty(new StringProperty())), null);
    assertEquals(jt.getRawClass(), String[].class);
}

From source file:com.ebuddy.cassandra.databind.CustomTypeResolverBuilder.java

private boolean useForType(JavaType t) {
    return t.isArrayType() || Collection.class.isAssignableFrom(t.getRawClass());
}

From source file:io.swagger.test.BodyParamExtractionTest.java

@Test
public void testConvertComplexBodyParamWithoutConfigMapping() throws Exception {
    Map<String, Model> definitions = new HashMap<String, Model>();

    Parameter parameter = new BodyParameter().schema(new RefModel("#/definitions/Person"));
    JavaType jt = utils.getTypeFromParameter(parameter, definitions);

    // will look up from the config model package and ref.simpleName of Person
    assertEquals(jt.getRawClass(), Person.class);
}

From source file:org.linkedin.util.json.jackson.MetadataStyleSerializerFactory.java

@Override
@SuppressWarnings("unchecked")
public JsonSerializer<Object> createSerializer(SerializerProvider prov, JavaType origType)
        throws JsonMappingException {
    JsonSerializer<Object> serializer = (JsonSerializer<Object>) SERIALIZERS
            .get(origType.getRawClass().getName());

    if (serializer != null)
        return serializer;

    if (origType.isContainerType())
        return super.createSerializer(prov, origType);
    else//from   w w  w  .  j a va2  s  . co m
        return ToStringSerializer.instance;
}

From source file:com.addthis.codec.jackson.CodecTypeResolverBuilder.java

@Override
public CodecTypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType,
        Collection<NamedType> subtypes) {
    CodecTypeIdResolver codecTypeIdResolver = idResolver(config, baseType, subtypes, false, true);
    Class<?> defaultImplForType = _defaultImpl;
    if ((_defaultImpl == null) || !baseType.getRawClass().isAssignableFrom(_defaultImpl)) {
        defaultImplForType = baseType.getRawClass();
    }/*from  w  w  w  .ja v  a2 s  . c  o m*/
    return new CodecTypeDeserializer(pluginMap, _includeAs, baseType, codecTypeIdResolver, _typeProperty,
            _typeIdVisible, typeFactory.constructSpecializedType(baseType, defaultImplForType));
}

From source file:org.emfjson.jackson.databind.ser.EMFSerializers.java

@Override
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) {
    if (type.isTypeOrSubTypeOf(Resource.class)) {
        return _resourceSerializer;
    }/*from w  ww.j a  va2 s.  c o  m*/

    if (type.isTypeOrSubTypeOf(Enumerator.class) && !type.isReferenceType()) {
        if (type.getRawClass() != EEnumLiteralImpl.class) {
            return _enumeratorSerializer;
        }
    }

    if (type.isReferenceType() || type.isTypeOrSubTypeOf(ReferenceEntry.class)) {
        return _referenceSerializer;
    }

    if (type.isTypeOrSubTypeOf(EcoreType.DataType.class)) {
        return _dataTypeSerializer;
    }

    if (type.isTypeOrSubTypeOf(EObject.class)) {
        return new EObjectSerializer(propertiesBuilder, _referenceSerializer);
    }

    return super.findSerializer(config, type, beanDesc);
}

From source file:java2typescript.jackson.module.visitors.TSJsonFormatVisitorWrapper.java

public EnumType parseEnumOrGetFromCache(Module module, JavaType javaType) {
    String name = getName(javaType);
    AbstractType namedType = module.getNamedTypes().get(name);
    if (namedType == null) {
        EnumType enumType = new EnumType(name, javaType.getRawClass());
        for (Object val : javaType.getRawClass().getEnumConstants()) {
            enumType.getValues().add(((Enum<?>) val).name());
        }/*from  ww w. j a  va2  s.  c o  m*/
        module.getNamedTypes().put(name, enumType);
        return enumType;
    } else {
        return (EnumType) namedType;
    }
}

From source file:com.github.mrenou.jacksonatic.internal.introspection.JacksonaticClassIntrospector.java

@Override
protected POJOPropertiesCollector collectProperties(MapperConfig<?> config, JavaType type, MixInResolver r,
        boolean forSerialization, String mutatorPrefix) {
    boolean useAnnotations = config.isAnnotationProcessingEnabled();
    AnnotatedClass ac;//from  w w w . j  a v  a2s. com
    if (forSerialization) {
        ac = annotatedClassConstructor.constructForSerialization(type.getRawClass(),
                (useAnnotations ? config.getAnnotationIntrospector() : null), r);
    } else {
        ac = annotatedClassConstructor.constructForDeserialization(type.getRawClass(),
                (useAnnotations ? config.getAnnotationIntrospector() : null), r);
    }
    POJOPropertiesCollector propertyCollector = constructPropertyCollector(config, ac, type, forSerialization,
            mutatorPrefix);
    return propertyCollector.collect();
}

From source file:java2typescript.jackson.module.visitors.TSJsonFormatVisitorWrapper.java

private TSJsonObjectFormatVisitor useNamedClassOrParse(JavaType javaType) {

    String name = getName(javaType);

    AbstractNamedType namedType = getModule().getNamedTypes().get(name);

    if (namedType == null) {
        TSJsonObjectFormatVisitor visitor = new TSJsonObjectFormatVisitor(this, name, javaType.getRawClass(),
                conf);//from  ww w .ja  va 2  s.  c o m
        type = visitor.getType();
        getModule().getNamedTypes().put(visitor.getType().getName(), visitor.getType());
        visitor.addPublicMethods();
        return visitor;
    } else {
        type = namedType;
        return null;
    }
}

From source file:com.github.mrenou.jacksonatic.internal.introspection.JacksonaticClassIntrospector.java

@Override
public BasicBeanDescription forDirectClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) {
    BasicBeanDescription desc = _findStdTypeDesc(type);
    if (desc == null) {
        boolean useAnnotations = cfg.isAnnotationProcessingEnabled();
        AnnotationIntrospector ai = cfg.getAnnotationIntrospector();
        AnnotatedClass ac = annotatedClassConstructor.constructWithoutSuperTypes(type.getRawClass(),
                (useAnnotations ? ai : null), r);
        desc = BasicBeanDescription.forOtherUse(cfg, type, ac);
    }/*from ww w .  j av a2s.  c om*/
    return desc;
}