Search in sources :

Example 1 with SubtypeResolver

use of com.fasterxml.jackson.databind.jsontype.SubtypeResolver in project jackson-databind by FasterXML.

the class ConfigObjectsTest method testSubtypeResolver.

public void testSubtypeResolver() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    SubtypeResolver res = mapper.getSubtypeResolver();
    assertTrue(res instanceof StdSubtypeResolver);
    StdSubtypeResolver repl = new StdSubtypeResolver();
    repl.registerSubtypes(Sub.class);
    mapper.setSubtypeResolver(repl);
    assertSame(repl, mapper.getSubtypeResolver());
}
Also used : SubtypeResolver(com.fasterxml.jackson.databind.jsontype.SubtypeResolver) StdSubtypeResolver(com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver) StdSubtypeResolver(com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver)

Example 2 with SubtypeResolver

use of com.fasterxml.jackson.databind.jsontype.SubtypeResolver in project druid by druid-io.

the class IncrementalIndexCreator method getAppendableIndexTypes.

/**
 * Fetch all the available incremental-index implementations.
 * It can be used to parametrize the test. If more parameters are needed, use indexTypeCartesianProduct().
 * @see #indexTypeCartesianProduct(Collection[]).
 *
 * @return a list of all the incremental-index implementations types (String)
 */
public static List<String> getAppendableIndexTypes() {
    SubtypeResolver resolver = JSON_MAPPER.getSubtypeResolver();
    MapperConfig<?> config = JSON_MAPPER.getDeserializationConfig();
    AnnotatedClass cls = AnnotatedClassResolver.resolveWithoutSuperTypes(config, AppendableIndexSpec.class);
    Collection<NamedType> types = resolver.collectAndResolveSubtypesByClass(config, cls);
    return types.stream().map(NamedType::getName).filter(Objects::nonNull).distinct().collect(Collectors.toList());
}
Also used : SubtypeResolver(com.fasterxml.jackson.databind.jsontype.SubtypeResolver) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) Objects(java.util.Objects)

Aggregations

SubtypeResolver (com.fasterxml.jackson.databind.jsontype.SubtypeResolver)2 AnnotatedClass (com.fasterxml.jackson.databind.introspect.AnnotatedClass)1 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)1 StdSubtypeResolver (com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver)1 Objects (java.util.Objects)1