Search in sources :

Example 21 with TypeFactory

use of com.fasterxml.jackson.databind.type.TypeFactory in project jackson-databind by FasterXML.

the class TestJDKSerialization method testTypeFactory.

public void testTypeFactory() throws Exception {
    TypeFactory orig = TypeFactory.defaultInstance();
    JavaType t = orig.constructType(JavaType.class);
    assertNotNull(t);
    byte[] bytes = jdkSerialize(orig);
    TypeFactory result = jdkDeserialize(bytes);
    assertNotNull(result);
    t = orig.constructType(JavaType.class);
    assertEquals(JavaType.class, t.getRawClass());
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Example 22 with TypeFactory

use of com.fasterxml.jackson.databind.type.TypeFactory in project jackson-databind by FasterXML.

the class TestCoreXMLTypes method testDeserializerLoading.

/*
    /**********************************************************
    /* Deserializer tests
    /**********************************************************
     */
// First things first: must be able to load the deserializers...
public void testDeserializerLoading() {
    CoreXMLDeserializers sers = new CoreXMLDeserializers();
    TypeFactory f = TypeFactory.defaultInstance();
    sers.findBeanDeserializer(f.constructType(Duration.class), null, null);
    sers.findBeanDeserializer(f.constructType(XMLGregorianCalendar.class), null, null);
    sers.findBeanDeserializer(f.constructType(QName.class), null, null);
}
Also used : CoreXMLDeserializers(com.fasterxml.jackson.databind.ext.CoreXMLDeserializers) QName(javax.xml.namespace.QName) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Example 23 with TypeFactory

use of com.fasterxml.jackson.databind.type.TypeFactory in project jackson-databind by FasterXML.

the class TestTypeResolution method testListViaTypeRef.

public void testListViaTypeRef() {
    TypeFactory tf = TypeFactory.defaultInstance();
    JavaType t = tf.constructType(new TypeReference<MyLongList<Integer>>() {
    });
    CollectionType type = (CollectionType) t;
    assertSame(MyLongList.class, type.getRawClass());
    assertEquals(tf.constructType(Long.class), type.getContentType());
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) CollectionType(com.fasterxml.jackson.databind.type.CollectionType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Example 24 with TypeFactory

use of com.fasterxml.jackson.databind.type.TypeFactory in project jackson-databind by FasterXML.

the class TestTypeResolution method testMaps.

/*
    /**********************************************************
    /* Test methods
    /**********************************************************
     */
public void testMaps() {
    TypeFactory tf = TypeFactory.defaultInstance();
    JavaType t = tf.constructType(new TypeReference<LongValuedMap<String>>() {
    });
    MapType type = (MapType) t;
    assertSame(LongValuedMap.class, type.getRawClass());
    assertEquals(tf.constructType(String.class), type.getKeyType());
    assertEquals(tf.constructType(Long.class), type.getContentType());
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory) MapType(com.fasterxml.jackson.databind.type.MapType)

Example 25 with TypeFactory

use of com.fasterxml.jackson.databind.type.TypeFactory in project jackson-databind by FasterXML.

the class TestTypeResolution method testListViaClass.

public void testListViaClass() {
    TypeFactory tf = TypeFactory.defaultInstance();
    JavaType t = tf.constructType(LongList.class);
    JavaType type = (CollectionType) t;
    assertSame(LongList.class, type.getRawClass());
    assertEquals(tf.constructType(Long.class), type.getContentType());
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) CollectionType(com.fasterxml.jackson.databind.type.CollectionType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Aggregations

TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)34 JavaType (com.fasterxml.jackson.databind.JavaType)14 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 IOException (java.io.IOException)8 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)4 CollectionType (com.fasterxml.jackson.databind.type.CollectionType)4 MapType (com.fasterxml.jackson.databind.type.MapType)4 List (java.util.List)4 ArrayList (java.util.ArrayList)3 MetricsModule (com.codahale.metrics.json.MetricsModule)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 PropertyNamingStrategy (com.fasterxml.jackson.databind.PropertyNamingStrategy)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 ArrayType (com.fasterxml.jackson.databind.type.ArrayType)2 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)2 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)2 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)2 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)2 Query (io.druid.query.Query)2