Package com.fasterxml.jackson.databind.type

Examples of com.fasterxml.jackson.databind.type.TypeFactory


                mapper._deserializationContext = mapper._deserializationContext.with(df);
            }

//          @Override
            public void addTypeModifier(TypeModifier modifier) {
                TypeFactory f = mapper._typeFactory;
                f = f.withModifier(modifier);
                mapper.setTypeFactory(f);
            }

//          @Override
            public void addValueInstantiators(ValueInstantiators instantiators) {
View Full Code Here


    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
        throws JsonMappingException
    {
        JsonArrayFormatVisitor arrayVisitor = (visitor == null) ? null : visitor.expectArrayFormat(typeHint);
        if (arrayVisitor != null) {
            TypeFactory tf = visitor.getProvider().getTypeFactory();
            JavaType contentType = tf.moreSpecificType(_elementType, typeHint.getContentType());
            if (contentType == null) {
                throw new JsonMappingException("Could not resolve type");
            }
            JsonSerializer<?> valueSer = _elementSerializer;
            if (valueSer == null) {
View Full Code Here

    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
        throws JsonMappingException
    {
        JsonArrayFormatVisitor arrayVisitor = visitor.expectArrayFormat(typeHint);
        if (arrayVisitor != null) {
            TypeFactory tf = visitor.getProvider().getTypeFactory();
            JavaType contentType = tf.moreSpecificType(_elementType, typeHint.getContentType());
            if (contentType == null) {
                throw new JsonMappingException("Could not resolve type");
            }
            JsonSerializer<?> valueSer = _elementSerializer;
            if (valueSer == null) {
View Full Code Here

        return findAdapterBoundType(adapter).isAssignableFrom(targetType);
    }

    private Class<?> findAdapterBoundType(XmlAdapter<?,?> adapter)
    {
        TypeFactory tf = getTypeFactory();
        JavaType adapterType = tf.constructType(adapter.getClass());
        JavaType[] params = tf.findTypeParameters(adapterType, XmlAdapter.class);
        // should not happen, except if our type resolution has a flaw, but:
        if (params == null || params.length < 2) {
            return Object.class;
        }
        return params[1].getRawClass();
View Full Code Here

          return conversionService.convert(value, TypeDescriptor.forObject(value),
              methodParameter.getTypeDescriptor());
        } catch (ConversionFailedException e) {
          // ignore this exception for collections and arrays.
          // try to convert the value with jackson
          TypeFactory typeFactory = configurationService.getJsonHandler().getMapper().getTypeFactory();
          if (methodParameter.getTypeDescriptor().isCollection()) {
            JavaType type = CollectionType.construct(
                methodParameter.getType(),
                typeFactory.constructType(methodParameter.getTypeDescriptor()
                    .getElementTypeDescriptor().getType()));
            return configurationService.getJsonHandler().convertValue(value, type);
          } else if (methodParameter.getTypeDescriptor().isArray()) {
            JavaType type = typeFactory.constructArrayType(methodParameter.getTypeDescriptor()
                .getElementTypeDescriptor().getType());
            return configurationService.getJsonHandler().convertValue(value, type);
          }

          throw e;
View Full Code Here

          return conversionService.convert(value, TypeDescriptor.forObject(value),
              methodParameter.getTypeDescriptor());
        } catch (ConversionFailedException e) {
          // ignore this exception for collections and arrays.
          // 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());
            return jsonHandler.convertValue(value, type);
          }

          throw e;
View Full Code Here

          return conversionService.convert(value, TypeDescriptor.forObject(value),
              methodParameter.getTypeDescriptor());
        } catch (ConversionFailedException e) {
          // ignore this exception for collections and arrays.
          // 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());
            return jsonHandler.convertValue(value, type);
          }

          throw e;
View Full Code Here

        }
       
        // [JACKSON-283]: AtomicReference is a rather special type...
        if (AtomicReference.class.isAssignableFrom(cls)) {
            // Must find parameterization
            TypeFactory tf = config.getTypeFactory();
            JavaType[] params = tf.findTypeParameters(type, AtomicReference.class);
            JavaType referencedType;
            if (params == null || params.length < 1) { // untyped (raw)
                referencedType = TypeFactory.unknownType();
            } else {
                referencedType = params[0];
View Full Code Here

        }

        if(plugin.isMethodAllowed(HttpMethod.GET) || plugin.isMethodAllowed(HttpMethod.POST))
            apis.add(buildApi(plugin,resourceBundle));

        TypeFactory typeFactory = objectMapper.getTypeFactory();

        if(plugin.isHistoryEnabled())
        {
            apis.add(buildHistory(plugin,resourceBundle));
            models.putAll(buildModels(String.format("%sHistoryResponse", plugin.getEndpointName()),
                    typeFactory.constructParametricType(HistoryResponse.class, Serializable.class, pluginVersion.getApiClass())));
        }

        api.setApis(apis);


        models.putAll(buildModels(endpoint, typeFactory.constructType(pluginVersion.getApiClass())));

        if(plugin.isMethodAllowed(HttpMethod.GET))
            models.putAll(buildModels(String.format("%sEntityResponse", plugin.getEndpointName()),
                    typeFactory.constructParametricType(EntityResponse.class, pluginVersion.getApiClass())));

        if(plugin.isMethodAllowed(HttpMethod.DELETE))
            models.putAll(buildModels(String.format("%sDeleteResponse", plugin.getEndpointName()),
                    typeFactory.constructType(DeleteResponse.class)));

        return api;
    }
View Full Code Here

          return conversionService.convert(value, TypeDescriptor.forObject(value),
              methodParameter.getTypeDescriptor());
        } catch (ConversionFailedException e) {
          // ignore this exception for collections and arrays.
          // 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());
            return jsonHandler.convertValue(value, type);
          }

          throw e;
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.type.TypeFactory

Copyright © 2018 www.massapicom. 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.