Examples of constructType()


Examples of com.facebook.presto.jdbc.internal.jackson.databind.type.TypeFactory.constructType()

    public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property)
        throws JsonMappingException
    {
        // First: figure out what is the fully generic delegate type:
        TypeFactory tf = provider.getTypeFactory();
        JavaType implType = tf.constructType(_converter.getClass());
        JavaType[] params = tf.findTypeParameters(implType, Converter.class);
        if (params == null || params.length != 2) {
            throw new JsonMappingException("Could not determine Converter parameterization for "
                    +implType);
        }
View Full Code Here

Examples of com.facebook.presto.jdbc.internal.jackson.databind.type.TypeFactory.constructType()

    public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property)
        throws JsonMappingException
    {
        // First: figure out what is the fully generic delegate type:
        TypeFactory tf = ctxt.getTypeFactory();
        JavaType implType = tf.constructType(_converter.getClass());
        JavaType[] params = tf.findTypeParameters(implType, Converter.class);
        if (params == null || params.length != 2) {
            throw new JsonMappingException("Could not determine Converter parameterization for "
                    +implType);
        }
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.constructType()

    resp.setContentType("application/json");
    ObjectMapper om = new ObjectMapper();
    try
    {
      ObjectWriter writer = om.writer().withType(om.constructType(getClass().getMethod("prototype").getGenericReturnType()));
      writer.writeValue(resp.getOutputStream(), Lists.newArrayList(one, two, three));
    }
    catch (Exception e)
    {
      throw new ServletException(e);
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.constructType()

    public void testJsonValueAnnotation() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(Leaf.class), visitor);
        JsonSchema schemaExp = visitor.finalSchema();
        assertNotNull(schemaExp);
       
        visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(ContainerWithAsValue.class), visitor);
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.constructType()

        mapper.acceptJsonFormatVisitor(mapper.constructType(Leaf.class), visitor);
        JsonSchema schemaExp = visitor.finalSchema();
        assertNotNull(schemaExp);
       
        visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(ContainerWithAsValue.class), visitor);
        JsonSchema schemaAct = visitor.finalSchema();
        assertNotNull(schemaAct);

        // these are minimal checks:
        assertEquals(schemaExp.getType(), schemaAct.getType());
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.constructType()

    public void testJsonValueForCollection() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(Issue34Bean.class), visitor);
        JsonSchema schema = visitor.finalSchema();
        assertNotNull(schema);
       
        String schemaStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
        assertNotNull(schemaStr);
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.constructType()

            URL schemaLocation = schemaLookup.getSchemaURL(schemaAnnotation.value());
            JsonSchema jsonSchema = cache.getSchema(schemaLocation);
            JsonNode jsonNode = mapper.readTree(jp);
            List<ErrorMessage> validationErrors = jsonSchema.validate(jsonNode);
            if (validationErrors.isEmpty()) {
                return mapper.reader().withType(mapper.constructType(genericType)).readValue(jsonNode);
            }

            throw new WebApplicationException(generateErrorMessage(validationErrors));
        } else {
            return super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
View Full Code Here

Examples of com.fasterxml.jackson.databind.SerializationConfig.constructType()

    Assert.notNull(mapper, "ObjectMapper must not be null!");
    Assert.notNull(type, "Type must not be null!");

    SerializationConfig serializationConfig = mapper.getSerializationConfig();
    JavaType javaType = serializationConfig.constructType(type);
    BeanDescription description = serializationConfig.introspect(javaType);

    this.definitions = description.findProperties();
  }
View Full Code Here

Examples of com.fasterxml.jackson.databind.type.TypeFactory.constructType()

      List<?> list = (List<?>) object;
      Object firstElement = list.get(0);
      return typeFactory.constructCollectionType(list.getClass(), constructType(firstElement));

    } else {
      return typeFactory.constructType(object.getClass());
    }
  }

}
View Full Code Here

Examples of com.fasterxml.jackson.databind.type.TypeFactory.constructType()

          // try to convert the value with jackson
          TypeFactory typeFactory = jsonHandler.getMapper().getTypeFactory();
          if (methodParameter.getTypeDescriptor().isCollection()) {
            JavaType type = CollectionType.construct(
                methodParameter.getType(),
                typeFactory.constructType(methodParameter.getTypeDescriptor()
                    .getElementTypeDescriptor().getType()));
            return jsonHandler.convertValue(value, type);
          } else if (methodParameter.getTypeDescriptor().isArray()) {
            JavaType type = typeFactory.constructArrayType(methodParameter.getTypeDescriptor()
                .getElementTypeDescriptor().getType());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.