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:org.apache.ode.jacob.soup.jackson.JacobTypeResolverBuilder.java

private boolean useForType(JavaType t) {
    if (Runnable.class.isAssignableFrom(t.getRawClass())) {
        return true;
    }//from  w  w  w . j a v  a  2  s.  c  o m

    //TODO: check if still needed.
    if (Channel.class.isAssignableFrom(t.getRawClass())) {
        return true;
    }

    if (CommChannel.class.isAssignableFrom(t.getRawClass())) {
        return true;
    }

    if (ChannelRef.class.isAssignableFrom(t.getRawClass())) {
        return true;
    }

    if (MessageListener.class.isAssignableFrom(t.getRawClass())) {
        return true;
    }

    if (t.getRawClass() == Object.class || t.isArrayType()) {
        return true;
    }

    return false;
}

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

@Override
public JsonStringFormatVisitor expectStringFormat(JavaType jType) throws JsonMappingException {
    if (jType.getRawClass().isEnum()) {
        type = parseEnumOrGetFromCache(getModule(), jType);
        return null;
    } else {//from   w w  w  . j  av a 2  s .  co m
        return setTypeAndReturn(new TSJsonStringFormatVisitor(this, conf));
    }
}

From source file:com.proofpoint.http.client.SmileBodyGenerator.java

public static <T> SmileBodyGenerator<T> smileBodyGenerator(JsonCodec<T> jsonCodec, T instance) {
    ObjectMapper objectMapper = OBJECT_MAPPER_SUPPLIER.get();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    JsonGenerator jsonGenerator;/*from   ww w  .  ja  v a2  s. c  o m*/
    try {
        jsonGenerator = new SmileFactory().createGenerator(out);
    } catch (IOException e) {
        throw propagate(e);
    }

    Type genericType = jsonCodec.getType();
    // 04-Mar-2010, tatu: How about type we were given? (if any)
    JavaType rootType = null;
    if (genericType != null && instance != null) {
        // 10-Jan-2011, tatu: as per [JACKSON-456], it's not safe to just force root
        // type since it prevents polymorphic type serialization. Since we really
        // just need this for generics, let's only use generic type if it's truly
        // generic.
        if (genericType.getClass() != Class.class) { // generic types are other implementations of 'java.lang.reflect.Type'
            // This is still not exactly right; should root type be further
            // specialized with 'value.getClass()'? Let's see how well this works before
            // trying to come up with more complete solution.
            rootType = objectMapper.getTypeFactory().constructType(genericType);
            // 26-Feb-2011, tatu: To help with [JACKSON-518], we better recognize cases where
            // type degenerates back into "Object.class" (as is the case with plain TypeVariable,
            // for example), and not use that.
            //
            if (rootType.getRawClass() == Object.class) {
                rootType = null;
            }
        }
    }

    try {
        if (rootType != null) {
            objectMapper.writerWithType(rootType).writeValue(jsonGenerator, instance);
        } else {
            objectMapper.writeValue(jsonGenerator, instance);
        }
    } catch (IOException e) {
        throw new IllegalArgumentException(
                String.format("%s could not be converted to SMILE", instance.getClass().getName()), e);
    }

    return new SmileBodyGenerator<>(out.toByteArray());
}

From source file:org.nuxeo.client.api.marshaller.NuxeoConverterFactory.java

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit client) {
    JavaType javaType = mapper.getTypeFactory().constructType(type);
    NuxeoMarshaller<?> nuxeoMarshaller = marshallers.get(javaType.getRawClass());
    if (nuxeoMarshaller != null) {
        return new NuxeoResponseConverterFactory<>(nuxeoMarshaller, mapper);
    }//from  ww w  .  j ava2s  . c om
    ObjectReader reader = mapper.readerFor(javaType);
    return new NuxeoResponseConverterFactory<>(reader, mapper, javaType);
}

From source file:org.nuxeo.client.api.marshaller.NuxeoConverterFactory.java

@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations,
        Annotation[] methodAnnotations, Retrofit retrofit) {
    JavaType javaType = mapper.getTypeFactory().constructType(type);
    NuxeoMarshaller<?> nuxeoMarshaller = marshallers.get(javaType.getRawClass());
    if (nuxeoMarshaller != null) {
        return new NuxeoRequestConverterFactory<>(nuxeoMarshaller, mapper);
    }/*from www  .  j  a  v  a 2 s .  c om*/
    ObjectWriter writer = mapper.writerFor(javaType);
    return new NuxeoRequestConverterFactory<>(writer, mapper, javaType);
}

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

@Test
public void getLongParameterClassTest() throws Exception {
    JavaType jt = utils.getTypeFromParameter(new QueryParameter().property(new LongProperty()), null);
    assertEquals(jt.getRawClass(), Long.class);
}

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

@Test
public void getDateParameterClassTest() throws Exception {
    JavaType jt = utils.getTypeFromParameter(new QueryParameter().property(new DateProperty()), null);
    assertEquals(jt.getRawClass(), LocalDate.class);
}

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

@Test
public void getFloatParameterClassTest() throws Exception {
    JavaType jt = utils.getTypeFromParameter(new QueryParameter().property(new FloatProperty()), null);
    assertEquals(jt.getRawClass(), Float.class);
}

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

@Test
public void getStringParameterClassTest() throws Exception {
    JavaType jt = utils.getTypeFromParameter(new QueryParameter().property(new StringProperty()), null);
    assertEquals(jt.getRawClass(), String.class);
}

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

@Test
public void getDoubleParameterClassTest() throws Exception {
    JavaType jt = utils.getTypeFromParameter(new QueryParameter().property(new DoubleProperty()), null);
    assertEquals(jt.getRawClass(), Double.class);
}