Java Code Examples for org.jboss.jandex.IndexView#getAllKnownSubclasses()

The following examples show how to use org.jboss.jandex.IndexView#getAllKnownSubclasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HibernateValidatorProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static void contributeClass(Set<DotName> classNamesCollector, IndexView indexView, DotName className) {
    classNamesCollector.add(className);
    for (ClassInfo subclass : indexView.getAllKnownSubclasses(className)) {
        if (Modifier.isAbstract(subclass.flags())) {
            // we can avoid adding the abstract classes here: either they are parent classes
            // and they will be dealt with by Hibernate Validator or they are child classes
            // without any proper implementation and we can ignore them.
            continue;
        }
        classNamesCollector.add(subclass.name());
    }
    for (ClassInfo implementor : indexView.getAllKnownImplementors(className)) {
        if (Modifier.isAbstract(implementor.flags())) {
            // we can avoid adding the abstract classes here: either they are parent classes
            // and they will be dealt with by Hibernate Validator or they are child classes
            // without any proper implementation and we can ignore them.
            continue;
        }
        classNamesCollector.add(implementor.name());
    }
}
 
Example 2
Source File: Types.java    From quarkus with Apache License 2.0 6 votes vote down vote up
static boolean isAssignableFrom(DotName class1, DotName class2, IndexView index) {
    // java.lang.Object is assignable from any type
    if (class1.equals(DotNames.OBJECT)) {
        return true;
    }
    // type1 is the same as type2
    if (class1.equals(class2)) {
        return true;
    }
    // type1 is a superclass
    Set<DotName> assignables = new HashSet<>();
    Collection<ClassInfo> subclasses = index.getAllKnownSubclasses(class1);
    for (ClassInfo subclass : subclasses) {
        assignables.add(subclass.name());
    }
    Collection<ClassInfo> implementors = index.getAllKnownImplementors(class1);
    for (ClassInfo implementor : implementors) {
        assignables.add(implementor.name());
    }
    return assignables.contains(class2);
}
 
Example 3
Source File: InfinispanEmbeddedProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private void addReflectionForName(String className, boolean isInterface, IndexView indexView,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass, boolean methods, boolean fields,
        Set<DotName> excludedClasses) {
    Collection<ClassInfo> classInfos;
    if (isInterface) {
        classInfos = indexView.getAllKnownImplementors(DotName.createSimple(className));
    } else {
        classInfos = indexView.getAllKnownSubclasses(DotName.createSimple(className));
    }

    classInfos.removeIf(ci -> excludedClasses.contains(ci.name()));

    if (!classInfos.isEmpty()) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(methods, fields,
                classInfos.stream().map(ClassInfo::toString).toArray(String[]::new)));
    }
}
 
Example 4
Source File: HttpClientProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerForReflection(
        CombinedIndexBuildItem index,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {

    IndexView view = index.getIndex();

    for (ClassInfo info : view.getAllKnownSubclasses(HTTP_REQUEST_BASE_NAME)) {
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, info.name().toString()));
    }
}
 
Example 5
Source File: SmallRyeMetricsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private void collectMetricsClassAndSubClasses(IndexView index, Map<DotName, ClassInfo> collectedMetricsClasses,
        ClassInfo clazz) {
    collectedMetricsClasses.put(clazz.name(), clazz);
    for (ClassInfo subClass : index.getAllKnownSubclasses(clazz.name())) {
        collectedMetricsClasses.put(subClass.name(), subClass);
    }
}
 
Example 6
Source File: HibernateSearchElasticsearchProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static void addReflectiveClass(IndexView index, Set<DotName> reflectiveClassCollector,
        Set<Type> reflectiveTypeCollector, ClassInfo classInfo) {
    if (skipClass(classInfo.name(), reflectiveClassCollector)) {
        return;
    }

    reflectiveClassCollector.add(classInfo.name());

    for (ClassInfo subclass : index.getAllKnownSubclasses(classInfo.name())) {
        reflectiveClassCollector.add(subclass.name());
    }
    for (ClassInfo implementor : index.getAllKnownImplementors(classInfo.name())) {
        reflectiveClassCollector.add(implementor.name());
    }

    Type superClassType = classInfo.superClassType();
    while (superClassType != null && !superClassType.name().toString().equals("java.lang.Object")) {
        reflectiveClassCollector.add(superClassType.name());
        if (superClassType instanceof ClassType) {
            superClassType = index.getClassByName(superClassType.name()).superClassType();
        } else if (superClassType instanceof ParameterizedType) {
            ParameterizedType parameterizedType = superClassType.asParameterizedType();
            for (Type typeArgument : parameterizedType.arguments()) {
                addReflectiveType(index, reflectiveClassCollector, reflectiveTypeCollector, typeArgument);
            }
            superClassType = parameterizedType.owner();
        }
    }
}
 
Example 7
Source File: DeploymentSupport.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
public static Iterable<ClassInfo> getAllKnownSubclasses(IndexView view, String name) {
    return view.getAllKnownSubclasses(DotName.createSimple(name));
}
 
Example 8
Source File: DeploymentSupport.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
public static Iterable<ClassInfo> getAllKnownSubclasses(IndexView view, Class<?> type) {
    return view.getAllKnownSubclasses(DotName.createSimple(type.getName()));
}
 
Example 9
Source File: DeploymentSupport.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
public static Iterable<ClassInfo> getAllKnownSubclasses(IndexView view, DotName type) {
    return view.getAllKnownSubclasses(type);
}