use of com.fasterxml.jackson.databind.introspect.AnnotatedClass 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());
}
use of com.fasterxml.jackson.databind.introspect.AnnotatedClass in project druid by druid-io.
the class InputSourceModuleTest method testSubTypeRegistration.
@Test
public void testSubTypeRegistration() {
MapperConfig config = mapper.getDeserializationConfig();
AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, SqlInputSource.class);
List<String> subtypes = mapper.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass).stream().map(NamedType::getName).collect(Collectors.toList());
Assert.assertNotNull(subtypes);
Assert.assertEquals(SQL_NAMED_TYPE, Iterables.getOnlyElement(subtypes));
}
use of com.fasterxml.jackson.databind.introspect.AnnotatedClass in project druid by druid-io.
the class FirehoseModuleTest method getFirehoseFactorySubtypeClasses.
private static Set<Class> getFirehoseFactorySubtypeClasses(ObjectMapper objectMapper) {
Class parentClass = FirehoseFactory.class;
MapperConfig config = objectMapper.getDeserializationConfig();
AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(parentClass, config);
Collection<NamedType> subtypes = objectMapper.getSubtypeResolver().collectAndResolveSubtypesByClass(config, ac);
Assert.assertNotNull(subtypes);
return subtypes.stream().map(NamedType::getType).filter(c -> !c.equals(parentClass)).collect(Collectors.toSet());
}
use of com.fasterxml.jackson.databind.introspect.AnnotatedClass in project jackson-databind by FasterXML.
the class TestAnnotatedClass method testFieldIntrospection.
public void testFieldIntrospection() {
SerializationConfig config = MAPPER.getSerializationConfig();
JavaType t = MAPPER.constructType(FieldBean.class);
AnnotatedClass ac = AnnotatedClass.construct(t, config);
// AnnotatedClass does not ignore non-visible fields, yet
assertEquals(2, ac.getFieldCount());
for (AnnotatedField f : ac.fields()) {
String fname = f.getName();
if (!"bar".equals(fname) && !"props".equals(fname)) {
fail("Unexpected field name '" + fname + "'");
}
}
}
use of com.fasterxml.jackson.databind.introspect.AnnotatedClass in project jackson-databind by FasterXML.
the class TestAnnotatedClass method testConstructorIntrospection.
// For [databind#1005]
public void testConstructorIntrospection() {
// Need this call to ensure there is a synthetic constructor being generated
// (not really needed otherwise)
Bean1005 bean = new Bean1005(13);
SerializationConfig config = MAPPER.getSerializationConfig();
JavaType t = MAPPER.constructType(bean.getClass());
AnnotatedClass ac = AnnotatedClass.construct(t, config);
assertEquals(1, ac.getConstructors().size());
}
Aggregations