Java 类com.fasterxml.jackson.databind.jsontype.NamedType 实例源码

项目:syndesis    文件:YamlHelpers.java   
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .registerModule(new Jdk8Module())
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
项目:Equella    文件:AttachmentSerializerProvider.java   
@Override
public void extendMapper(ObjectMapper mapper)
{
    List<AttachmentSerializer> serializers = tracker.getBeanList();
    for( AttachmentSerializer attachmentSerializer : serializers )
    {
        Map<String, Class<? extends EquellaAttachmentBean>> types = attachmentSerializer.getAttachmentBeanTypes();
        if( types != null )
        {
            for( Entry<String, Class<? extends EquellaAttachmentBean>> entry : types.entrySet() )
            {
                mapper.registerSubtypes(new NamedType(entry.getValue(), entry.getKey()));
            }
        }
    }
}
项目:syndesis-integration-runtime    文件:YamlHelpers.java   
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
项目:netty-rest    文件:SwaggerJacksonAnnotationIntrospector.java   
@Override
public List<NamedType> findSubtypes(Annotated a)
{
    final ApiModel api = a.getAnnotation(ApiModel.class);
    if (api != null) {
        final Class<?>[] classes = api.subTypes();
        final List<NamedType> names = new ArrayList<>(classes.length);
        for (Class<?> subType : classes) {
            names.add(new NamedType(subType));
        }
        if (!names.isEmpty()) {
            return names;
        }
    }

    return Collections.emptyList();
}
项目:spring-cloud-bus    文件:RemoteApplicationEventScanTests.java   
private void assertConverterBeanAfterPropertiesSet(
        final String[] expectedPackageToScan,
        final Class<?>... expectedRegisterdClasses) {
    final ObjectMapper mapper = (ObjectMapper) ReflectionTestUtils.getField(converter,
            "mapper");

    @SuppressWarnings("unchecked")
    final LinkedHashSet<NamedType> registeredSubtypes = (LinkedHashSet<NamedType>) ReflectionTestUtils
            .getField(mapper.getSubtypeResolver(), "_registeredSubtypes");

    final List<Class<?>> expectedRegisterdClassesAsList = new ArrayList<>(
            Arrays.asList(expectedRegisterdClasses));
    addStandardSpringCloudEventBusEvents(expectedRegisterdClassesAsList);

    assertTrue("Wrong RemoteApplicationEvent classes are registerd in object mapper",
            expectedRegisterdClassesAsList.size() == registeredSubtypes.size());

    for (final NamedType namedType : registeredSubtypes) {
        assertTrue(expectedRegisterdClassesAsList.contains(namedType.getType()));
    }

    assertThat("RemoteApplicationEvent packages not registered",
            Arrays.asList((String[]) ReflectionTestUtils.getField(converter, "packagesToScan")),
            containsInAnyOrder(expectedPackageToScan));

}
项目:QuizUpWinner    文件:StdSubtypeResolver.java   
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass paramAnnotatedClass, MapperConfig<?> paramMapperConfig, AnnotationIntrospector paramAnnotationIntrospector)
{
  HashMap localHashMap = new HashMap();
  if (this._registeredSubtypes != null)
  {
    Class localClass = paramAnnotatedClass.getRawType();
    Iterator localIterator = this._registeredSubtypes.iterator();
    while (localIterator.hasNext())
    {
      NamedType localNamedType = (NamedType)localIterator.next();
      if (localClass.isAssignableFrom(localNamedType.getType()))
        _collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(localNamedType.getType(), paramAnnotationIntrospector, paramMapperConfig), localNamedType, paramMapperConfig, paramAnnotationIntrospector, localHashMap);
    }
  }
  _collectAndResolve(paramAnnotatedClass, new NamedType(paramAnnotatedClass.getRawType(), null), paramMapperConfig, paramAnnotationIntrospector, localHashMap);
  return new ArrayList(localHashMap.values());
}
项目:QuizUpWinner    文件:StdTypeResolverBuilder.java   
public TypeDeserializer buildTypeDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, Collection<NamedType> paramCollection)
{
  if (this._idType == JsonTypeInfo.Id.NONE)
    return null;
  TypeIdResolver localTypeIdResolver = idResolver(paramDeserializationConfig, paramJavaType, paramCollection, false, true);
  switch (1.$SwitchMap$com$fasterxml$jackson$annotation$JsonTypeInfo$As[this._includeAs.ordinal()])
  {
  default:
    break;
  case 1:
    return new AsArrayTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
  case 2:
    return new AsPropertyTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
  case 3:
    return new AsWrapperTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
  case 4:
    return new AsExternalTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
  }
  throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: " + this._includeAs);
}
项目:QuizUpWinner    文件:StdTypeResolverBuilder.java   
public TypeSerializer buildTypeSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType, Collection<NamedType> paramCollection)
{
  if (this._idType == JsonTypeInfo.Id.NONE)
    return null;
  TypeIdResolver localTypeIdResolver = idResolver(paramSerializationConfig, paramJavaType, paramCollection, true, false);
  switch (1.$SwitchMap$com$fasterxml$jackson$annotation$JsonTypeInfo$As[this._includeAs.ordinal()])
  {
  default:
    break;
  case 1:
    return new AsArrayTypeSerializer(localTypeIdResolver, null);
  case 2:
    return new AsPropertyTypeSerializer(localTypeIdResolver, null, this._typeProperty);
  case 3:
    return new AsWrapperTypeSerializer(localTypeIdResolver, null);
  case 4:
    return new AsExternalTypeSerializer(localTypeIdResolver, null, this._typeProperty);
  }
  throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: " + this._includeAs);
}
项目:QuizUpWinner    文件:StdTypeResolverBuilder.java   
protected TypeIdResolver idResolver(MapperConfig<?> paramMapperConfig, JavaType paramJavaType, Collection<NamedType> paramCollection, boolean paramBoolean1, boolean paramBoolean2)
{
  if (this._customIdResolver != null)
    return this._customIdResolver;
  if (this._idType == null)
    throw new IllegalStateException("Can not build, 'init()' not yet called");
  switch (1.$SwitchMap$com$fasterxml$jackson$annotation$JsonTypeInfo$Id[this._idType.ordinal()])
  {
  default:
    break;
  case 1:
    return new ClassNameIdResolver(paramJavaType, paramMapperConfig.getTypeFactory());
  case 2:
    return new MinimalClassNameIdResolver(paramJavaType, paramMapperConfig.getTypeFactory());
  case 3:
    return TypeNameIdResolver.construct(paramMapperConfig, paramJavaType, paramCollection, paramBoolean1, paramBoolean2);
  case 4:
    return null;
  }
  throw new IllegalStateException("Do not know how to construct standard type id resolver for idType: " + this._idType);
}
项目:storm-example    文件:DruidStateFactory.java   
private static synchronized void startRealtime() {
    if (rn == null) {
        final Lifecycle lifecycle = new Lifecycle();
        rn = RealtimeNode.builder().build();
        lifecycle.addManagedInstance(rn);
        rn.registerJacksonSubtype(new NamedType(StormFirehoseFactory.class, "storm"));
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                LOG.info("Running shutdown hook");
                lifecycle.stop();
            }
        }));

        try {
            lifecycle.start();
        } catch (Throwable t) {
            LOG.info("Throwable caught at startup, committing seppuku", t);
            t.printStackTrace();
            System.exit(2);
        }
    }
}
项目:storm-example    文件:DruidStateFactory.java   
private static synchronized void startRealtime() {
    if (rn == null) {
        final Lifecycle lifecycle = new Lifecycle();
        rn = RealtimeNode.builder().build();
        lifecycle.addManagedInstance(rn);
        rn.registerJacksonSubtype(new NamedType(StormFirehoseFactory.class, "storm"));
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                LOG.info("Running shutdown hook");
                lifecycle.stop();
            }
        }));

        try {
            lifecycle.start();
        } catch (Throwable t) {
            LOG.info("Throwable caught at startup, committing seppuku", t);
            t.printStackTrace();
            System.exit(2);
        }
    }
}
项目:codec    文件:CodecTypeIdResolver.java   
public CodecTypeIdResolver(PluginMap pluginMap, JavaType baseType,
                           TypeFactory typeFactory, Collection<NamedType> subtypes,
                           PluginRegistry pluginRegistry) {
    super(baseType, typeFactory);
    this.pluginRegistry = pluginRegistry;
    if (!subtypes.isEmpty()) {
        BiMap<String, Class<?>> mutableExtraSubTypes = HashBiMap.create(subtypes.size());
        for (NamedType namedType : subtypes) {
            if (namedType.hasName()) {
                mutableExtraSubTypes.put(namedType.getName(), namedType.getType());
            }
        }
        this.extraSubTypes = Maps.unmodifiableBiMap(mutableExtraSubTypes);
    } else {
        this.extraSubTypes = ImmutableBiMap.of();
    }
    this.pluginMap = pluginMap;
}
项目:codec    文件:CodecIntrospector.java   
/** report all non-alias plugin types */
@Override
public List<NamedType> findSubtypes(Annotated a) {
    Pluggable pluggable = a.getAnnotation(Pluggable.class);
    PluginMap pluginMap;
    if (pluggable != null) {
        pluginMap = pluginRegistry.byCategory().get(pluggable.value());
    } else if (pluginRegistry.byClass().containsKey(a.getRawType())) {
        pluginMap = pluginRegistry.byClass().get(a.getRawType());
    } else {
        return null;
    }
    List<NamedType> result = new ArrayList<>(pluginMap.asBiMap().size());
    for (Map.Entry<String, Class<?>> type : pluginMap.asBiMap().entrySet()) {
        result.add(new NamedType(type.getValue(), type.getKey()));
    }
    return result;
}
项目:bandwidth-on-demand    文件:AppComponents.java   
@Bean
public ObjectMapper jacksonObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();

  mapper.setVisibility(
      mapper.getSerializationConfig().getDefaultVisibilityChecker()
          .withFieldVisibility(Visibility.ANY)
          .withGetterVisibility(Visibility.NONE)
          .withSetterVisibility(Visibility.NONE)
          .withCreatorVisibility(Visibility.NONE)
          .withIsGetterVisibility(Visibility.NONE));
  SimpleModule module = new SimpleModule("bandwidth-on-demand", Version.unknownVersion());
  module.addSerializer(new VlanJsonSerializer());
  module.addDeserializer(Vlan.class, new VlanJsonDeserializer());
  module.addSerializer(new ScheduleTypeJsonSerializer());
  module.addDeserializer(ScheduleType.class, new ScheduleTypeJsonDeserializer());
  mapper.registerModule(module);
  mapper.registerModule(new Hibernate4Module());
  mapper.registerModule(new JodaModule());
  mapper.registerModule(new Jdk8Module());
  mapper.registerModule(new JavaTimeModule());
  mapper.registerSubtypes(new NamedType(LocalVirtualPort.class, "LOCAL"));
  mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

  return mapper;
}
项目:joyplus-tv    文件:StdSubtypeResolver.java   
@Override
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type,
        MapperConfig<?> config, AnnotationIntrospector ai)
{
    HashMap<NamedType, NamedType> subtypes = new HashMap<NamedType, NamedType>();
    // [JACKSON-257] then consider registered subtypes (which have precedence over annotations)
    if (_registeredSubtypes != null) {
        Class<?> rawBase = type.getRawType();
        for (NamedType subtype : _registeredSubtypes) {
            // is it a subtype of root type?
            if (rawBase.isAssignableFrom(subtype.getType())) { // yes
                AnnotatedClass curr = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), ai, config);
                _collectAndResolve(curr, subtype, config, ai, subtypes);
            }
        }
    }
    // and then check subtypes via annotations from base type (recursively)
    NamedType rootType = new NamedType(type.getRawType(), null);
    _collectAndResolve(type, rootType, config, ai, subtypes);
    return new ArrayList<NamedType>(subtypes.values());
}
项目:joyplus-tv    文件:StdTypeResolverBuilder.java   
public TypeSerializer buildTypeSerializer(SerializationConfig config,
        JavaType baseType, Collection<NamedType> subtypes)
{
    if (_idType == JsonTypeInfo.Id.NONE) {
        return null;
    }
    TypeIdResolver idRes = idResolver(config, baseType, subtypes, true, false);
    switch (_includeAs) {
    case WRAPPER_ARRAY:
        return new AsArrayTypeSerializer(idRes, null);
    case PROPERTY:
        return new AsPropertyTypeSerializer(idRes, null,
                _typeProperty);
    case WRAPPER_OBJECT:
        return new AsWrapperTypeSerializer(idRes, null);
    case EXTERNAL_PROPERTY:
        return new AsExternalTypeSerializer(idRes, null,
                _typeProperty);
    }
    throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: "+_includeAs);
}
项目:joyplus-tv    文件:StdTypeResolverBuilder.java   
public TypeDeserializer buildTypeDeserializer(DeserializationConfig config,
        JavaType baseType, Collection<NamedType> subtypes)
{
    if (_idType == JsonTypeInfo.Id.NONE) {
        return null;
    }

    TypeIdResolver idRes = idResolver(config, baseType, subtypes, false, true);

    // First, method for converting type info to type id:
    switch (_includeAs) {
    case WRAPPER_ARRAY:
        return new AsArrayTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    case PROPERTY:
        return new AsPropertyTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    case WRAPPER_OBJECT:
        return new AsWrapperTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    case EXTERNAL_PROPERTY:
        return new AsExternalTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    }
    throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: "+_includeAs);
}
项目:joyplus-tv    文件:StdTypeResolverBuilder.java   
/**
 * Helper method that will either return configured custom
 * type id resolver, or construct a standard resolver
 * given configuration.
 */
protected TypeIdResolver idResolver(MapperConfig<?> config,
        JavaType baseType, Collection<NamedType> subtypes,
        boolean forSer, boolean forDeser)
{
    // Custom id resolver?
    if (_customIdResolver != null) {
        return _customIdResolver;
    }
    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }
    switch (_idType) {
    case CLASS:
        return new ClassNameIdResolver(baseType, config.getTypeFactory());
    case MINIMAL_CLASS:
        return new MinimalClassNameIdResolver(baseType, config.getTypeFactory());
    case NAME:
        return TypeNameIdResolver.construct(config, baseType, subtypes, forSer, forDeser);
    case NONE: // hmmh. should never get this far with 'none'
        return null;
    case CUSTOM: // need custom resolver...
    }
    throw new IllegalStateException("Do not know how to construct standard type id resolver for idType: "+_idType);
}
项目:joyplus-tv    文件:BeanSerializerFactory.java   
/**
 * Method called to create a type information serializer for values of given
 * container property
 * if one is needed. If not needed (no polymorphic handling configured), should
 * return null.
 *
 * @param containerType Declared type of the container to use as the base type for type information serializer
 * 
 * @return Type serializer to use for property value contents, if one is needed; null if not.
 */    
public TypeSerializer findPropertyContentTypeSerializer(JavaType containerType,
        SerializationConfig config, AnnotatedMember accessor)
    throws JsonMappingException
{
    JavaType contentType = containerType.getContentType();
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, accessor, containerType);        
    // Defaulting: if no annotations on member, check value class
    if (b == null) {
        return createTypeSerializer(config, contentType);
    }
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(accessor,
            config, ai, contentType);
    return b.buildTypeSerializer(config, contentType, subtypes);
}
项目:joyplus-tv    文件:BasicSerializerFactory.java   
/**
 * Method called to construct a type serializer for values with given declared
 * base type. This is called for values other than those of bean property
 * types.
 */
@Override
public TypeSerializer createTypeSerializer(SerializationConfig config,
        JavaType baseType)
{
    BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass());
    AnnotatedClass ac = bean.getClassInfo();
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType);
    /* Ok: if there is no explicit type info handler, we may want to
     * use a default. If so, config object knows what to use.
     */
    Collection<NamedType> subtypes = null;
    if (b == null) {
        b = config.getDefaultTyper(baseType);
    } else {
        subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(ac, config, ai);
    }
    if (b == null) {
        return null;
    }
    return b.buildTypeSerializer(config, baseType, subtypes);
}
项目:joyplus-tv    文件:BasicDeserializerFactory.java   
/**
 * Method called to create a type information deserializer for values of
 * given non-container property, if one is needed.
 * If not needed (no polymorphic handling configured for property), should return null.
 *<p>
 * Note that this method is only called for non-container bean properties,
 * and not for values in container types or root values (or container properties)
 *
 * @param baseType Declared base type of the value to deserializer (actual
 *    deserializer type will be this type or its subtype)
 * 
 * @return Type deserializer to use for given base type, if one is needed; null if not.
 */
public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config,
        JavaType baseType, AnnotatedMember annotated)
    throws JsonMappingException
{
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, annotated, baseType);        
    // Defaulting: if no annotations on member, check value class
    if (b == null) {
        return findTypeDeserializer(config, baseType);
    }
    // but if annotations found, may need to resolve subtypes:
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(
            annotated, config, ai, baseType);
    return b.buildTypeDeserializer(config, baseType, subtypes);
}
项目:joyplus-tv    文件:BasicDeserializerFactory.java   
/**
 * Method called to find and create a type information deserializer for values of
 * given container (list, array, map) property, if one is needed.
 * If not needed (no polymorphic handling configured for property), should return null.
 *<p>
 * Note that this method is only called for container bean properties,
 * and not for values in container types or root values (or non-container properties)
 * 
 * @param containerType Type of property; must be a container type
 * @param propertyEntity Field or method that contains container property
 */    
public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config,
        JavaType containerType, AnnotatedMember propertyEntity)
    throws JsonMappingException
{
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, propertyEntity, containerType);        
    JavaType contentType = containerType.getContentType();
    // Defaulting: if no annotations on member, check class
    if (b == null) {
        return findTypeDeserializer(config, contentType);
    }
    // but if annotations found, may need to resolve subtypes:
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(
            propertyEntity, config, ai, contentType);
    return b.buildTypeDeserializer(config, contentType, subtypes);
}
项目:Equella    文件:FileMapperExtension.java   
@Override
public void extendMapper(ObjectMapper mapper)
{
    mapper.registerSubtypes(new NamedType(RootFolderBean.class, RootFolderBean.TYPE));
    mapper.registerSubtypes(new NamedType(FolderBean.class, FolderBean.TYPE));
    mapper.registerSubtypes(new NamedType(FileBean.class, FileBean.TYPE));
    mapper.registerSubtypes(new NamedType(GenericFileBean.class, GenericFileBean.TYPE));
}
项目:spring-credhub    文件:JsonUtils.java   
/**
 * Configure type mapping for the {@literal value} field in the {@literal CredentialDetails}
 * object.
 *
 * @param objectMapper the {@link ObjectMapper} to configure
 */
private static void configureCredentialDetailTypeMapping(ObjectMapper objectMapper) {
    List<NamedType> subtypes = new ArrayList<NamedType>();
    for (CredentialType type : CredentialType.values()) {
        subtypes.add(new NamedType(type.getModelClass(), type.getValueType()));
    }

    registerSubtypes(objectMapper, subtypes);
}
项目:jasperreports    文件:JacksonUtil.java   
/**
 *
 */
private static void register(ObjectMapper mapper, JacksonMapping mapping)
{
    try
    {
        Class<?> clazz = Class.forName(mapping.getClassName());
        mapper.registerSubtypes(new NamedType(clazz, mapping.getName()));
    }
    catch (ClassNotFoundException e)
    {
        throw new JRRuntimeException(e);
    }
}
项目:druid-example-extension    文件:ExampleExtensionModule.java   
@Override
public List<? extends Module> getJacksonModules()
{
  // Register Jackson module for any classes we need to be able to use in JSON queries or ingestion specs.
  return ImmutableList.of(
      new SimpleModule(getClass().getSimpleName()).registerSubtypes(
          new NamedType(ExampleSumAggregatorFactory.class, ExampleSumAggregatorFactory.TYPE_NAME),
          new NamedType(ExampleExtractionFn.class, ExampleExtractionFn.TYPE_NAME)
      )
  );
}
项目:stinift    文件:HivePlugin.java   
@Override
public void register(SimpleModule pluginModule, SimpleModule resourceModule) {
    pluginModule.addAbstractTypeMapping(Reader.Creator.class, HiveReader.Creator.class);
    pluginModule.registerSubtypes(new NamedType(HiveReader.Creator.class, "hive"));

    pluginModule.addAbstractTypeMapping(Writer.Creator.class, HiveWriter.Creator.class);
    pluginModule.registerSubtypes(new NamedType(HiveWriter.Creator.class, "hive"));

    resourceModule.addAbstractTypeMapping(Resource.Creator.class, HiveConnection.Creator.class);
    resourceModule.registerSubtypes(new NamedType(HiveConnection.Creator.class, "hive"));
}
项目:stinift    文件:MysqlPlugin.java   
@Override
public void register(SimpleModule pluginModule, SimpleModule resourceModule) {
    pluginModule.addAbstractTypeMapping(Reader.Creator.class, MysqlReader.Creator.class);
    pluginModule.registerSubtypes(new NamedType(MysqlReader.Creator.class, "mysql"));

    pluginModule.addAbstractTypeMapping(Writer.Creator.class, MysqlWriter.Creator.class);
    pluginModule.registerSubtypes(new NamedType(MysqlWriter.Creator.class, "mysql"));

    resourceModule.addAbstractTypeMapping(Resource.Creator.class, MysqlConnection.Creator.class);
    resourceModule.registerSubtypes(new NamedType(MysqlConnection.Creator.class, "mysql"));
}
项目:stinift    文件:MongoPlugin.java   
@Override
public void register(SimpleModule pluginModule, SimpleModule resourceModule) {
    pluginModule.addAbstractTypeMapping(Reader.Creator.class, MongoReader.Creator.class);
    pluginModule.registerSubtypes(new NamedType(MongoReader.Creator.class, "mongo"));

    resourceModule.addAbstractTypeMapping(Resource.Creator.class, MongoConnection.Creator.class);
    resourceModule.registerSubtypes(new NamedType(MongoConnection.Creator.class, "mongo"));
}
项目:stinift    文件:HbasePlugin.java   
@Override
public void register(SimpleModule pluginModule, SimpleModule resourceModule) {
    pluginModule.addAbstractTypeMapping(Writer.Creator.class, HBaseWriter.Creator.class);
    pluginModule.registerSubtypes(new NamedType(HBaseWriter.Creator.class, "hbase"));

    resourceModule.addAbstractTypeMapping(Resource.Creator.class, HBaseConnection.Creator.class);
    resourceModule.registerSubtypes(new NamedType(HBaseConnection.Creator.class, "hbase"));
}
项目:graphql-spqr    文件:JacksonValueMapperFactory.java   
private Map<Type, List<NamedType>> collectSubtypes(Set<Type> abstractTypes, String[] basePackages, TypeInfoGenerator metaDataGen) {
    Map<Type, List<NamedType>> types = new HashMap<>();
    Set<Class<?>> abstractClasses = abstractTypes.stream()
            .map(ClassUtils::getRawType)
            .distinct()
            .collect(Collectors.toSet());
    for (Class abstractClass : abstractClasses) {
        List<NamedType> subTypes = ClassUtils.findImplementations(abstractClass, basePackages).stream()
                .filter(impl -> !ClassUtils.isAbstract(impl))
                .map(sub -> new NamedType(sub, metaDataGen.generateTypeName(GenericTypeReflector.annotate(sub))))
                .collect(Collectors.toList());
        types.put(abstractClass, subTypes);
    }
    return types;
}
项目:graphql-spqr    文件:AnnotationIntrospector.java   
@Override
public List<NamedType> findSubtypes(Annotated a) {
    List<NamedType> original = super.findSubtypes(a);
    if ((original == null || original.isEmpty()) && typeMap.containsKey(a.getRawType())) {
        return typeMap.get(a.getRawType());
    }
    return original;
}
项目:fahrschein    文件:MetadataTypeResolver.java   
@Override
public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
    final TypeNameIdResolver typeNameIdResolver = TypeNameIdResolver.construct(config, baseType, subtypes, false, true);
    return new MetadataTypeDeserializer(
            baseType,
            typeNameIdResolver,
            this.defaultImpl == null ? null : config.getTypeFactory().constructSpecializedType(baseType, this.defaultImpl));
}
项目:bootique    文件:ImmutableSubtypeResolver.java   
@Override
public void registerSubtypes(NamedType... types) {
    if (locked) {
        throw new UnsupportedOperationException("This object is immutable");
    } else {
        super.registerSubtypes(types);
    }
}
项目:heroic    文件:QueryTest.java   
@Before
public void setup() {
    mapper = new ObjectMapper();
    mapper.addMixIn(Aggregation.class, TypeNameMixin.class);
    mapper.registerModule(new Jdk8Module());
    mapper.registerSubtypes(new NamedType(Group.class, Group.NAME));
    mapper.registerSubtypes(new NamedType(Empty.class, Empty.NAME));
}
项目:clotho3crud    文件:WideningDefaultTypeResolverBuilder.java   
@Override
protected TypeIdResolver idResolver(MapperConfig<?> config, JavaType baseType, Collection<NamedType> subtypes, boolean forSer, boolean forDeser) {
    if (_customIdResolver != null) {
        return _customIdResolver;
    }
    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }
    if (_idType == JsonTypeInfo.Id.CLASS){
        return new WideningClassNameIdResolver(baseType, config.getTypeFactory());
    }
    return super.idResolver(config, baseType, subtypes, forSer, forDeser); //To change body of generated methods, choose Tools | Templates.
}
项目:components    文件:NsTypeResolverBuilder.java   
@Override
protected TypeIdResolver idResolver(MapperConfig<?> config, JavaType baseType, Collection<NamedType> subtypes,
        boolean forSer, boolean forDeser) {

    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }

    return new NsTypeIdResolver(baseType, config.getTypeFactory(), basicMetaData);
}
项目:QuizUpWinner    文件:TypeNameIdResolver.java   
public static TypeNameIdResolver construct(MapperConfig<?> paramMapperConfig, JavaType paramJavaType, Collection<NamedType> paramCollection, boolean paramBoolean1, boolean paramBoolean2)
{
  if (paramBoolean1 == paramBoolean2)
    throw new IllegalArgumentException();
  HashMap localHashMap1 = null;
  if (paramBoolean1)
    localHashMap1 = new HashMap();
  HashMap localHashMap2 = null;
  if (paramBoolean2)
    localHashMap2 = new HashMap();
  if (paramCollection != null)
  {
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext())
    {
      NamedType localNamedType = (NamedType)localIterator.next();
      Class localClass = localNamedType.getType();
      String str;
      if (localNamedType.hasName())
        str = localNamedType.getName();
      else
        str = _defaultTypeId(localClass);
      if (paramBoolean1)
        localHashMap1.put(localClass.getName(), str);
      if (paramBoolean2)
      {
        JavaType localJavaType = (JavaType)localHashMap2.get(str);
        if ((localJavaType == null) || (!localClass.isAssignableFrom(localJavaType.getRawClass())))
          localHashMap2.put(str, paramMapperConfig.constructType(localClass));
      }
    }
  }
  return new TypeNameIdResolver(paramMapperConfig, paramJavaType, localHashMap1, localHashMap2);
}
项目:QuizUpWinner    文件:StdSubtypeResolver.java   
public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember paramAnnotatedMember, MapperConfig<?> paramMapperConfig, AnnotationIntrospector paramAnnotationIntrospector, JavaType paramJavaType)
{
  Class localClass;
  if (paramJavaType == null)
    localClass = paramAnnotatedMember.getRawType();
  else
    localClass = paramJavaType.getRawClass();
  HashMap localHashMap = new HashMap();
  if (this._registeredSubtypes != null)
  {
    Iterator localIterator2 = this._registeredSubtypes.iterator();
    while (localIterator2.hasNext())
    {
      NamedType localNamedType3 = (NamedType)localIterator2.next();
      if (localClass.isAssignableFrom(localNamedType3.getType()))
        _collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(localNamedType3.getType(), paramAnnotationIntrospector, paramMapperConfig), localNamedType3, paramMapperConfig, paramAnnotationIntrospector, localHashMap);
    }
  }
  List localList = paramAnnotationIntrospector.findSubtypes(paramAnnotatedMember);
  if (localList != null)
  {
    Iterator localIterator1 = localList.iterator();
    while (localIterator1.hasNext())
    {
      NamedType localNamedType2 = (NamedType)localIterator1.next();
      _collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(localNamedType2.getType(), paramAnnotationIntrospector, paramMapperConfig), localNamedType2, paramMapperConfig, paramAnnotationIntrospector, localHashMap);
    }
  }
  NamedType localNamedType1 = new NamedType(localClass, null);
  _collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(localClass, paramAnnotationIntrospector, paramMapperConfig), localNamedType1, paramMapperConfig, paramAnnotationIntrospector, localHashMap);
  return new ArrayList(localHashMap.values());
}
项目:QuizUpWinner    文件:StdSubtypeResolver.java   
public void registerSubtypes(NamedType[] paramArrayOfNamedType)
{
  if (this._registeredSubtypes == null)
    this._registeredSubtypes = new LinkedHashSet();
  int i = paramArrayOfNamedType.length;
  for (int j = 0; j < i; j++)
  {
    NamedType localNamedType = paramArrayOfNamedType[j];
    this._registeredSubtypes.add(localNamedType);
  }
}