类com.fasterxml.jackson.databind.deser.std.StdDelegatingDeserializer源码实例Demo

下面列出了怎么用com.fasterxml.jackson.databind.deser.std.StdDelegatingDeserializer的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: JavaUtilCollectionsDeserializers.java
public static JsonDeserializer<?> findForCollection(DeserializationContext ctxt,
        JavaType type)
    throws JsonMappingException
{
    JavaUtilCollectionsConverter conv;

    // 10-Jan-2017, tatu: Some types from `java.util.Collections`/`java.util.Arrays` need bit of help...
    if (type.hasRawClass(CLASS_AS_ARRAYS_LIST)) {
        conv = converter(TYPE_AS_LIST, type, List.class);
    } else if (type.hasRawClass(CLASS_SINGLETON_LIST)) {
        conv = converter(TYPE_SINGLETON_LIST, type, List.class);
    } else if (type.hasRawClass(CLASS_SINGLETON_SET)) {
        conv = converter(TYPE_SINGLETON_SET, type, Set.class);
    } else if (type.hasRawClass(CLASS_UNMODIFIABLE_LIST)) {
        conv = converter(TYPE_UNMODIFIABLE_LIST, type, List.class);
    } else if (type.hasRawClass(CLASS_UNMODIFIABLE_SET)) {
        conv = converter(TYPE_UNMODIFIABLE_SET, type, Set.class);
    } else {
        return null;
    }
    return new StdDelegatingDeserializer<Object>(conv);
}
 
源代码2 项目: lams   文件: JavaUtilCollectionsDeserializers.java
public static JsonDeserializer<?> findForMap(DeserializationContext ctxt,
        JavaType type)
    throws JsonMappingException
{
    JavaUtilCollectionsConverter conv;

    // 10-Jan-2017, tatu: Some types from `java.util.Collections`/`java.util.Arrays` need bit of help...
    if (type.hasRawClass(CLASS_SINGLETON_MAP)) {
        conv = converter(TYPE_SINGLETON_MAP, type, Map.class);
    } else if (type.hasRawClass(CLASS_UNMODIFIABLE_MAP)) {
        conv = converter(TYPE_UNMODIFIABLE_MAP, type, Map.class);
    } else {
        return null;
    }
    return new StdDelegatingDeserializer<Object>(conv);
}
 
源代码3 项目: lams   文件: BeanDeserializerBase.java
/**
     * Helper method that can be used to see if specified property is annotated
     * to indicate use of a converter for property value (in case of container types,
     * it is container type itself, not key or content type).
     *<p>
     * NOTE: returned deserializer is NOT yet contextualized, caller needs to take
     * care to do that.
     *
     * @since 2.2
     */
    protected JsonDeserializer<Object> findConvertingDeserializer(DeserializationContext ctxt,
            SettableBeanProperty prop)
        throws JsonMappingException
    {
        final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();
        if (intr != null) {
            Object convDef = intr.findDeserializationConverter(prop.getMember());
            if (convDef != null) {
                Converter<Object,Object> conv = ctxt.converterInstance(prop.getMember(), convDef);
                JavaType delegateType = conv.getInputType(ctxt.getTypeFactory());
                // 25-Mar-2017, tatu: should not yet contextualize
//                JsonDeserializer<?> deser = ctxt.findContextualValueDeserializer(delegateType, prop);
                JsonDeserializer<?> deser = ctxt.findNonContextualValueDeserializer(delegateType);
                return new StdDelegatingDeserializer<Object>(conv, delegateType, deser);
            }
        }
        return null;
    }
 
源代码4 项目: Bats   文件: PhysicalPlanReader.java
public PhysicalPlanReader(DrillConfig config, ScanResult scanResult, LogicalPlanPersistence lpPersistance,
                          final DrillbitEndpoint endpoint, final StoragePluginRegistry pluginRegistry) {

  ObjectMapper lpMapper = lpPersistance.getMapper();

  // Endpoint serializer/deserializer.
  SimpleModule serDeModule = new SimpleModule("PhysicalOperatorModule")
      .addSerializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.Se())
      .addDeserializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.De())
      .addSerializer(MajorType.class, new MajorTypeSerDe.Se())
      .addDeserializer(MajorType.class, new MajorTypeSerDe.De())
      .addDeserializer(DynamicPojoRecordReader.class,
          new StdDelegatingDeserializer<>(new DynamicPojoRecordReader.Converter(lpMapper)))
      .addSerializer(Path.class, new PathSerDe.Se());

  lpMapper.registerModule(serDeModule);
  Set<Class<? extends PhysicalOperator>> subTypes = PhysicalOperatorUtil.getSubTypes(scanResult);
  subTypes.forEach(lpMapper::registerSubtypes);
  lpMapper.registerSubtypes(DynamicPojoRecordReader.class);
  InjectableValues injectables = new InjectableValues.Std()
      .addValue(StoragePluginRegistry.class, pluginRegistry)
      .addValue(DrillbitEndpoint.class, endpoint);

  this.mapper = lpMapper;
  this.physicalPlanReader = mapper.readerFor(PhysicalPlan.class).with(injectables);
  this.operatorReader = mapper.readerFor(PhysicalOperator.class).with(injectables);
  this.logicalPlanReader = mapper.readerFor(LogicalPlan.class).with(injectables);
}
 
源代码5 项目: lams   文件: DeserializerCache.java
/**
 * Helper method that will check whether given annotated entity (usually class,
 * but may also be a property accessor) indicates that a {@link Converter} is to
 * be used; and if so, to construct and return suitable serializer for it.
 * If not, will simply return given serializer as is.
 */
protected JsonDeserializer<Object> findConvertingDeserializer(DeserializationContext ctxt,
        Annotated a, JsonDeserializer<Object> deser)
    throws JsonMappingException
{
    Converter<Object,Object> conv = findConverter(ctxt, a);
    if (conv == null) {
        return deser;
    }
    JavaType delegateType = conv.getInputType(ctxt.getTypeFactory());
    return (JsonDeserializer<Object>) new StdDelegatingDeserializer<Object>(conv, delegateType, deser);
}
 
源代码6 项目: batfish   文件: RangeSetDeserializer.java
@Override
protected @Nonnull StdDelegatingDeserializer<RangeSet<?>> withDelegate(
    Converter<Object, RangeSet<?>> converter,
    JavaType delegateType,
    JsonDeserializer<?> delegateDeserializer) {
  return new StdDelegatingDeserializer<>(converter, delegateType, delegateDeserializer);
}
 
源代码7 项目: lams   文件: DeserializerCache.java
/**
 * Method that does the heavy lifting of checking for per-type annotations,
 * find out full type, and figure out which actual factory method
 * to call.
 */
@SuppressWarnings("unchecked")
protected JsonDeserializer<Object> _createDeserializer(DeserializationContext ctxt,
        DeserializerFactory factory, JavaType type)
    throws JsonMappingException
{
    final DeserializationConfig config = ctxt.getConfig();

    // First things first: do we need to use abstract type mapping?
    if (type.isAbstract() || type.isMapLikeType() || type.isCollectionLikeType()) {
        type = factory.mapAbstractType(config, type);
    }
    BeanDescription beanDesc = config.introspect(type);
    // Then: does type define explicit deserializer to use, with annotation(s)?
    JsonDeserializer<Object> deser = findDeserializerFromAnnotation(ctxt,
            beanDesc.getClassInfo());
    if (deser != null) {
        return deser;
    }

    // If not, may have further type-modification annotations to check:
    JavaType newType = modifyTypeByAnnotation(ctxt, beanDesc.getClassInfo(), type);
    if (newType != type) {
        type = newType;
        beanDesc = config.introspect(newType);
    }

    // We may also have a Builder type to consider...
    Class<?> builder = beanDesc.findPOJOBuilder();
    if (builder != null) {
        return (JsonDeserializer<Object>) factory.createBuilderBasedDeserializer(
        		ctxt, type, beanDesc, builder);
    }

    // Or perhaps a Converter?
    Converter<Object,Object> conv = beanDesc.findDeserializationConverter();
    if (conv == null) { // nope, just construct in normal way
        return (JsonDeserializer<Object>) _createDeserializer2(ctxt, factory, type, beanDesc);
    }
    // otherwise need to do bit of introspection
    JavaType delegateType = conv.getInputType(ctxt.getTypeFactory());
    // One more twist, as per [databind#288]; probably need to get new BeanDesc
    if (!delegateType.hasRawClass(type.getRawClass())) {
        beanDesc = config.introspect(delegateType);
    }
    return new StdDelegatingDeserializer<Object>(conv, delegateType,
            _createDeserializer2(ctxt, factory, delegateType, beanDesc));
}
 
 类方法
 同包方法