use of org.jboss.jandex.Type.Kind in project smallrye-graphql by smallrye.
the class JandexAnnotationsLoader method onMethod.
@Override
public Annotations onMethod(Class<?> type, String methodName, Class<?>... argTypes) {
ClassInfo classInfo = getClassInfo(type);
Type[] jandexArgTypes = Stream.of(argTypes).map(Class::getName).map(JandexAnnotationsLoader::createClassType).toArray(Type[]::new);
MethodInfo methodInfo = classInfo.method(methodName, jandexArgTypes);
if (methodInfo == null) {
String[] argTypeNames = Stream.of(argTypes).map(Class::getName).toArray(String[]::new);
throw new RuntimeException("no method " + signature(methodName, argTypeNames) + " in class " + classInfo.name());
}
// noinspection DuplicatedCode
return new Annotations() {
@Override
public Stream<Annotation> all() {
return methodInfo.annotations().stream().filter(// not params
annotationInstance -> annotationInstance.target().kind() == METHOD).flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations).map(JandexAnnotationsLoader::proxy);
}
@Override
public <T extends Annotation> Optional<T> get(Class<T> type) {
return all(type).collect(toOptionalOrThrow());
}
@Override
public <T extends Annotation> Stream<T> all(Class<T> type) {
DotName typeName = toDotName(type);
return methodInfo.annotations().stream().flatMap(JandexAnnotationsLoader::resolveRepeatableAnnotations).filter(annotationInstance -> annotationInstance.name().equals(typeName)).map(JandexAnnotationsLoader::proxy);
}
};
}
Aggregations