org.jboss.jandex.DotName Java Examples
The following examples show how to use
org.jboss.jandex.DotName.
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: DotNamesTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void testCreate() throws IOException { DotName nested = DotNames.create(Nested.class); assertTrue(nested.isComponentized()); assertEquals("io.quarkus.arc.processor.DotNamesTest$Nested", nested.toString()); assertEquals("DotNamesTest$Nested", nested.local()); assertEquals("DotNamesTest$Nested", nested.withoutPackagePrefix()); assertFalse(nested.isInner()); DotName nestedNested = DotNames.create(NestedNested.class); assertTrue(nestedNested.isComponentized()); assertEquals("io.quarkus.arc.processor.DotNamesTest$Nested$NestedNested", nestedNested.toString()); assertEquals("DotNamesTest$Nested$NestedNested", nestedNested.local()); assertEquals("DotNamesTest$Nested$NestedNested", nestedNested.withoutPackagePrefix()); assertFalse(nestedNested.isInner()); }
Example #2
Source File: ParameterProcessor.java From smallrye-open-api with Apache License 2.0 | 6 votes |
/** * Read a single annotation that is either {@link @Parameter} or * {@link @Parameters}. The results are stored in the private {@link #params} * collection. * * @param annotation a parameter annotation to be read and processed */ void readParameterAnnotation(AnnotationInstance annotation) { DotName name = annotation.name(); if (ParameterConstant.DOTNAME_PARAMETER.equals(name)) { readAnnotatedType(annotation, null, false); } else if (ParameterConstant.DOTNAME_PARAMETERS.equals(name)) { AnnotationValue annotationValue = annotation.value(); if (annotationValue != null) { /* * Unwrap annotations wrapped by @Parameters and * identify the target as the target of the @Parameters annotation */ for (AnnotationInstance nested : annotationValue.asNestedArray()) { readAnnotatedType(AnnotationInstance.create(nested.name(), annotation.target(), nested.values()), null, false); } } } }
Example #3
Source File: TypeResolver.java From smallrye-open-api with Apache License 2.0 | 6 votes |
private static int compareAnnotation(AnnotationTarget t1, AnnotationTarget t2, DotName annotationName) { boolean hasAnno1 = TypeUtil.hasAnnotation(t1, annotationName); boolean hasAnno2 = TypeUtil.hasAnnotation(t2, annotationName); // Element with @Schema is top priority if (hasAnno1) { if (!hasAnno2) { return -1; } } else { if (hasAnno2) { return 1; } } return 0; }
Example #4
Source File: RESTEasyExtension.java From quarkus with Apache License 2.0 | 6 votes |
private void scanAsyncResponseProvidersFromClassName(Class<?> asyncResponseProviderClass, String name) { try { Class<?> klass = Class.forName(name); if (asyncResponseProviderClass.isAssignableFrom(klass)) { for (java.lang.reflect.Type type : klass.getGenericInterfaces()) { if (type instanceof java.lang.reflect.ParameterizedType) { java.lang.reflect.ParameterizedType pType = (java.lang.reflect.ParameterizedType) type; if (pType.getRawType().equals(asyncResponseProviderClass) && pType.getActualTypeArguments().length == 1) { java.lang.reflect.Type asyncType = pType.getActualTypeArguments()[0]; String asyncTypeName; if (asyncType instanceof java.lang.reflect.ParameterizedType) asyncTypeName = ((java.lang.reflect.ParameterizedType) asyncType).getRawType().getTypeName(); else asyncTypeName = asyncType.getTypeName(); asyncTypes.add(DotName.createSimple(asyncTypeName)); } } } } } catch (ClassNotFoundException x) { // ignore it } }
Example #5
Source File: PicocliProcessor.java From quarkus with Apache License 2.0 | 6 votes |
@BuildStep void picocliRunner(ApplicationIndexBuildItem applicationIndex, CombinedIndexBuildItem combinedIndex, BuildProducer<AdditionalBeanBuildItem> additionalBean, BuildProducer<QuarkusApplicationClassBuildItem> quarkusApplicationClass, BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformer) { IndexView index = combinedIndex.getIndex(); Collection<DotName> topCommands = classesAnnotatedWith(index, TopCommand.class.getName()); if (topCommands.isEmpty()) { List<DotName> commands = classesAnnotatedWith(applicationIndex.getIndex(), CommandLine.Command.class.getName()); if (commands.size() == 1) { annotationsTransformer.produce(createAnnotationTransformer(commands.get(0))); } } if (index.getAnnotations(DotName.createSimple(QuarkusMain.class.getName())).isEmpty()) { additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(PicocliRunner.class)); additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(DefaultPicocliCommandLineFactory.class)); quarkusApplicationClass.produce(new QuarkusApplicationClassBuildItem(PicocliRunner.class)); } }
Example #6
Source File: SpringSecurityProcessorUtil.java From quarkus with Apache License 2.0 | 6 votes |
static ClassInfo getClassInfoFromBeanName(String beanName, IndexView index, Map<String, DotName> springBeansNameToDotName, Map<String, ClassInfo> springBeansNameToClassInfo, String expression, MethodInfo methodInfo) { ClassInfo beanClassInfo = springBeansNameToClassInfo.get(beanName); if (beanClassInfo == null) { DotName beanClassDotName = springBeansNameToDotName.get(beanName); if (beanClassDotName == null) { throw new IllegalArgumentException("Could not find bean named '" + beanName + "' found in expression" + expression + "' in the @PreAuthorize annotation on method " + methodInfo.name() + " of class " + methodInfo.declaringClass() + " in the set of the application beans"); } beanClassInfo = index.getClassByName(beanClassDotName); if (beanClassInfo == null) { throw new IllegalStateException("Unable to locate class " + beanClassDotName + " in the index"); } springBeansNameToClassInfo.put(beanName, beanClassInfo); } return beanClassInfo; }
Example #7
Source File: JaxRsAnnotationScanner.java From smallrye-open-api with Apache License 2.0 | 6 votes |
static Optional<String[]> getMediaTypes(MethodInfo resourceMethod, DotName annotationName) { AnnotationInstance annotation = resourceMethod.annotation(annotationName); if (annotation == null) { annotation = JandexUtil.getClassAnnotation(resourceMethod.declaringClass(), annotationName); } if (annotation != null) { AnnotationValue annotationValue = annotation.value(); if (annotationValue != null) { return Optional.of(annotationValue.asStringArray()); } return Optional.of(OpenApiConstants.DEFAULT_MEDIA_TYPES.get()); } return Optional.empty(); }
Example #8
Source File: StockMethodsAdder.java From quarkus with Apache License 2.0 | 6 votes |
private AnnotationTarget getIdAnnotationTargetRec(DotName currentDotName, IndexView index, DotName originalEntityDotName) { ClassInfo classInfo = index.getClassByName(currentDotName); if (classInfo == null) { throw new IllegalStateException("Entity " + originalEntityDotName + " was not part of the Quarkus index"); } if (!classInfo.annotations().containsKey(DotNames.JPA_ID)) { if (DotNames.OBJECT.equals(classInfo.superName())) { throw new IllegalArgumentException("Currently only Entities with the @Id annotation are supported. " + "Offending class is " + originalEntityDotName); } return getIdAnnotationTargetRec(classInfo.superName(), index, originalEntityDotName); } List<AnnotationInstance> annotationInstances = classInfo.annotations().get(DotNames.JPA_ID); if (annotationInstances.size() > 1) { throw new IllegalArgumentException( "Currently the @Id annotation can only be placed on a single field or method. " + "Offending class is " + originalEntityDotName); } return annotationInstances.get(0).target(); }
Example #9
Source File: BeanDefiningAnnotationStereotypeTestCase.java From quarkus with Apache License 2.0 | 6 votes |
static Consumer<BuildChainBuilder> buildCustomizer() { return new Consumer<BuildChainBuilder>() { @Override public void accept(BuildChainBuilder builder) { builder.addBuildStep(new BuildStep() { @Override public void execute(BuildContext context) { context.produce(new BeanDefiningAnnotationBuildItem(DotName.createSimple(MakeItBean.class.getName()), DotName.createSimple(ApplicationScoped.class.getName()))); } }).produces(BeanDefiningAnnotationBuildItem.class).build(); } }; }
Example #10
Source File: HibernateSearchElasticsearchProcessor.java From quarkus with Apache License 2.0 | 6 votes |
private static void addReflectiveType(IndexView index, Set<DotName> reflectiveClassCollector, Set<Type> reflectiveTypeCollector, Type type) { if (type instanceof VoidType || type instanceof PrimitiveType || type instanceof UnresolvedTypeVariable) { return; } else if (type instanceof ClassType) { ClassInfo classInfo = index.getClassByName(type.name()); addReflectiveClass(index, reflectiveClassCollector, reflectiveTypeCollector, classInfo); } else if (type instanceof ArrayType) { addReflectiveType(index, reflectiveClassCollector, reflectiveTypeCollector, type.asArrayType().component()); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = type.asParameterizedType(); addReflectiveType(index, reflectiveClassCollector, reflectiveTypeCollector, parameterizedType.owner()); for (Type typeArgument : parameterizedType.arguments()) { addReflectiveType(index, reflectiveClassCollector, reflectiveTypeCollector, typeArgument); } } }
Example #11
Source File: ResteasyServerCommonProcessor.java From quarkus with Apache License 2.0 | 6 votes |
private static void scanMethodParameters(DotName annotationType, BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy, IndexView index) { Collection<AnnotationInstance> instances = index.getAnnotations(annotationType); for (AnnotationInstance instance : instances) { if (instance.target().kind() != Kind.METHOD) { continue; } MethodInfo method = instance.target().asMethod(); String source = method.declaringClass() + "[" + method + "]"; reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem(method.returnType(), index, ResteasyDotNames.IGNORE_FOR_REFLECTION_PREDICATE, source)); for (short i = 0; i < method.parameters().size(); i++) { Type parameterType = method.parameters().get(i); if (!hasAnnotation(method, i, ResteasyDotNames.CONTEXT)) { reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem(parameterType, index, ResteasyDotNames.IGNORE_FOR_REFLECTION_PREDICATE, source)); } } } }
Example #12
Source File: SmallRyeMetricsProcessor.java From quarkus with Apache License 2.0 | 6 votes |
/** * Obtains the MetricType from a bean that is a producer method or field, * or null if no MetricType can be detected. */ private MetricType getMetricType(ClassInfo clazz) { DotName name = clazz.name(); if (name.equals(GAUGE_INTERFACE)) { return MetricType.GAUGE; } if (name.equals(COUNTER_INTERFACE)) { return MetricType.COUNTER; } if (name.equals(CONCURRENT_GAUGE_INTERFACE)) { return MetricType.CONCURRENT_GAUGE; } if (name.equals(HISTOGRAM_INTERFACE)) { return MetricType.HISTOGRAM; } if (name.equals(SIMPLE_TIMER_INTERFACE)) { return MetricType.SIMPLE_TIMER; } if (name.equals(TIMER_INTERFACE)) { return MetricType.TIMER; } if (name.equals(METER_INTERFACE)) { return MetricType.METERED; } return null; }
Example #13
Source File: InterfaceConfigPropertiesUtil.java From quarkus with Apache License 2.0 | 6 votes |
/** * Add a method like this: * * <pre> * @Produces * public SomeConfig produceSomeClass(Config config) { * return new SomeConfigQuarkusImpl(config) * } * </pre> */ static void addProducerMethodForInterfaceConfigProperties(ClassCreator classCreator, DotName interfaceName, String prefix, boolean needsQualifier, String generatedClassName) { String methodName = "produce" + interfaceName.withoutPackagePrefix(); if (needsQualifier) { // we need to differentiate the different producers of the same class methodName = methodName + "WithPrefix" + HashUtil.sha1(prefix); } try (MethodCreator method = classCreator.getMethodCreator(methodName, interfaceName.toString(), Config.class.getName())) { method.addAnnotation(Produces.class); if (needsQualifier) { method.addAnnotation(AnnotationInstance.create(DotNames.CONFIG_PREFIX, null, new AnnotationValue[] { AnnotationValue.createStringValue("value", prefix) })); } else { method.addAnnotation(Default.class); } method.returnValue(method.newInstance(MethodDescriptor.ofConstructor(generatedClassName, Config.class), method.getMethodParam(0))); } }
Example #14
Source File: VertxWebProcessor.java From quarkus with Apache License 2.0 | 6 votes |
private void validateRouteMethod(BeanInfo bean, MethodInfo method, DotName[] validParamTypes) { if (!method.returnType().kind().equals(Type.Kind.VOID)) { throw new IllegalStateException( String.format("Route handler business method must return void [method: %s, bean: %s]", method, bean)); } List<Type> params = method.parameters(); boolean hasInvalidParam = true; if (params.size() == 1) { DotName paramTypeName = params.get(0).name(); for (DotName type : validParamTypes) { if (type.equals(paramTypeName)) { hasInvalidParam = false; } } } if (hasInvalidParam) { throw new IllegalStateException(String.format( "Route business method must accept exactly one parameter of type %s: %s [method: %s, bean: %s]", validParamTypes, params, method, bean)); } }
Example #15
Source File: ConfigPropertiesUtil.java From quarkus with Apache License 2.0 | 5 votes |
/** * Generates code that uses Config#getValue for simple objects, or SmallRyeConfig#getValues if it is a Collection * type. * * @param propertyName Property name that needs to be fetched * @param resultType Type to which the property value needs to be converted to * @param declaringClass Config class where the type was encountered * @param bytecodeCreator Where the bytecode will be generated * @param config Reference to the MP config object */ static ResultHandle createReadMandatoryValueAndConvertIfNeeded(String propertyName, Type resultType, DotName declaringClass, BytecodeCreator bytecodeCreator, ResultHandle config) { if (isCollection(resultType)) { ResultHandle smallryeConfig = bytecodeCreator.checkCast(config, SmallRyeConfig.class); Class<?> factoryToUse = DotNames.SET.equals(resultType.name()) ? HashSetFactory.class : ArrayListFactory.class; ResultHandle collectionFactory = bytecodeCreator.invokeStaticMethod( MethodDescriptor.ofMethod(factoryToUse, "getInstance", factoryToUse)); return bytecodeCreator.invokeVirtualMethod( MethodDescriptor.ofMethod(SmallRyeConfig.class, "getValues", Collection.class, String.class, Class.class, IntFunction.class), smallryeConfig, bytecodeCreator.load(propertyName), bytecodeCreator.loadClass(determineSingleGenericType(resultType, declaringClass).name().toString()), collectionFactory); } else { return bytecodeCreator.invokeInterfaceMethod( MethodDescriptor.ofMethod(Config.class, "getValue", Object.class, String.class, Class.class), config, bytecodeCreator.load(propertyName), bytecodeCreator.loadClass(resultType.name().toString())); } }
Example #16
Source File: SmallRyeFaultToleranceProcessor.java From quarkus with Apache License 2.0 | 5 votes |
private boolean hasFTAnnotations(IndexView index, AnnotationStore annotationStore, ClassInfo info) { if (info == null) { //should not happen, but guard against it //happens in this case due to a bug involving array types return false; } // first check annotations on type if (annotationStore.hasAnyAnnotation(info, FT_ANNOTATIONS)) { return true; } // then check on the methods for (MethodInfo method : info.methods()) { if (annotationStore.hasAnyAnnotation(method, FT_ANNOTATIONS)) { return true; } } // then check on the parent DotName parentClassName = info.superName(); if (parentClassName == null || parentClassName.equals(DotNames.OBJECT)) { return false; } ClassInfo parentClassInfo = index.getClassByName(parentClassName); if (parentClassInfo == null) { return false; } return hasFTAnnotations(index, annotationStore, parentClassInfo); }
Example #17
Source File: ArrayCreatorTest.java From smallrye-graphql with Apache License 2.0 | 5 votes |
@Test public void shouldCreateArrayForCompletionStageOfList() { final ParameterizedType stringList = ParameterizedType.create(DotName.createSimple(List.class.getName()), new Type[] { STRING_TYPE }, null); final ParameterizedType completionStage = ParameterizedType.create(Classes.COMPLETION_STAGE, new Type[] { stringList }, null); assertTrue(ArrayCreator.createArray(completionStage).isPresent()); }
Example #18
Source File: AdditionalInterceptorBindingsTest.java From quarkus with Apache License 2.0 | 5 votes |
@Override public Map<DotName, Set<String>> registerAdditionalBindings() { Map<DotName, Set<String>> newBindings = new HashMap<>(); newBindings.put(DotName.createSimple(ToBeBinding.class.getName()), Collections.emptySet()); HashSet<String> value = new HashSet<>(); value.add("value"); newBindings.put(DotName.createSimple(ToBeBindingWithNonBindingField.class.getName()), value); newBindings.put(DotName.createSimple(ToBeBindingWithBindingField.class.getName()), Collections.emptySet()); return newBindings; }
Example #19
Source File: JaxRsAnnotationScanner.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Build a map between exception class name and its corresponding @ApiResponse annotation in the jax-rs exception mapper * */ private Map<DotName, AnnotationInstance> processExceptionMappers(final AnnotationScannerContext context) { Map<DotName, AnnotationInstance> exceptionHandlerMap = new HashMap<>(); Collection<ClassInfo> exceptionMappers = context.getIndex() .getKnownDirectImplementors(JaxRsConstants.EXCEPTION_MAPPER); for (ClassInfo classInfo : exceptionMappers) { DotName exceptionDotName = classInfo.interfaceTypes() .stream() .filter(it -> it.name().equals(JaxRsConstants.EXCEPTION_MAPPER)) .filter(it -> it.kind() == Type.Kind.PARAMETERIZED_TYPE) .map(Type::asParameterizedType) .map(type -> type.arguments().get(0)) // ExceptionMapper<?> has a single type argument .map(Type::name) .findFirst() .orElse(null); if (exceptionDotName == null) { continue; } MethodInfo toResponseMethod = classInfo.method(JaxRsConstants.TO_RESPONSE_METHOD_NAME, Type.create(exceptionDotName, Type.Kind.CLASS)); if (ResponseReader.hasResponseCodeValue(toResponseMethod)) { exceptionHandlerMap.put(exceptionDotName, ResponseReader.getResponseAnnotation(toResponseMethod)); } } return exceptionHandlerMap; }
Example #20
Source File: FilteredIndexViewTest.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@Test public void testAccepts_ExcludedClass_IncludedClassPattern() { Map<String, Object> properties = new HashMap<>(); properties.put(OASConfig.SCAN_CLASSES, "^(?:com.example.pkgA.My.*)$"); properties.put(OASConfig.SCAN_EXCLUDE_CLASSES, "com.example.pkgA.MyImpl"); OpenApiConfig config = IndexScannerTestBase.dynamicConfig(properties); FilteredIndexView view = new FilteredIndexView(null, config); assertTrue(view.accepts(DotName.createSimple("com.example.pkgA.MyBean"))); assertTrue(view.accepts(DotName.createSimple("com.example.pkgA.MyClass"))); assertFalse(view.accepts(DotName.createSimple("com.example.pkgA.MyImpl"))); }
Example #21
Source File: ValueResolverGenerator.java From quarkus with Apache License 2.0 | 5 votes |
/** * * @param index * @param classOutput * @param uncontrolled The map of {@link TemplateData} metadata for classes that are not controlled by the client */ ValueResolverGenerator(IndexView index, ClassOutput classOutput, Map<DotName, AnnotationInstance> uncontrolled) { this.analyzedTypes = new HashSet<>(); this.generatedTypes = new HashSet<>(); this.classOutput = classOutput; this.index = index; this.uncontrolled = uncontrolled != null ? uncontrolled : Collections.emptyMap(); }
Example #22
Source File: TypeInfos.java From quarkus with Apache License 2.0 | 5 votes |
static Info create(String typeInfo, Expression.Part part, IndexView index, Function<String, String> templateIdToPathFun, Origin expressionOrigin) { if (typeInfo.startsWith(TYPE_INFO_SEPARATOR)) { int endIdx = typeInfo.substring(1, typeInfo.length()).indexOf(Expressions.TYPE_INFO_SEPARATOR); if (endIdx < 1) { throw new IllegalArgumentException("Invalid type info: " + typeInfo); } String classStr = typeInfo.substring(1, endIdx + 1); if (classStr.equals(Expressions.TYPECHECK_NAMESPACE_PLACEHOLDER)) { return new Info(typeInfo, part); } else { DotName rawClassName = rawClassName(classStr); ClassInfo rawClass = index.getClassByName(rawClassName); if (rawClass == null) { throw new TemplateException( "Class [" + rawClassName + "] used in the parameter declaration in template [" + templateIdToPathFun.apply(expressionOrigin.getTemplateGeneratedId()) + "] on line " + expressionOrigin.getLine() + " was not found in the application index. Make sure it is spelled correctly."); } Type resolvedType = resolveType(classStr); return new TypeInfo(typeInfo, part, helperHint(typeInfo.substring(endIdx, typeInfo.length())), resolvedType, rawClass); } } else if (part.isVirtualMethod()) { return new VirtualMethodInfo(typeInfo, part.asVirtualMethod()); } else { String hint = helperHint(typeInfo); if (hint != null) { typeInfo = typeInfo.substring(0, typeInfo.indexOf(LEFT_ANGLE)); } return new PropertyInfo(typeInfo, part, hint); } }
Example #23
Source File: TypeUtil.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Convenience method to retrieve the named parameter from an annotation bound to the target. * The value will be unwrapped from its containing {@link AnnotationValue}. * * @param <T> the type of the parameter being retrieved * @param target the target object annotated with the annotation named by annotationName * @param annotationName name of the annotation from which to retrieve the value * @param propertyName the name of the parameter/property in the annotation * @param defaultValue a default value to return if either the annotation or the value are missing * @return an unwrapped annotation parameter value */ public static <T> T getAnnotationValue(AnnotationTarget target, DotName annotationName, String propertyName, T defaultValue) { AnnotationInstance annotation = getAnnotation(target, annotationName); if (annotation != null) { return JandexUtil.value(annotation, propertyName); } return defaultValue; }
Example #24
Source File: BeanInfoTypesTest.java From quarkus with Apache License 2.0 | 5 votes |
@Test public void testResolver() throws IOException { Index index = index(Foo.class, Bar.class, FooQualifier.class, AbstractList.class, AbstractCollection.class, Collection.class, List.class, Iterable.class, Object.class, String.class); BeanDeployment deployment = BeanProcessor.builder().setIndex(index).build().getBeanDeployment(); DotName fooName = name(Foo.class); ClassInfo fooClass = index.getClassByName(fooName); BeanInfo fooBean = Beans.createClassBean(fooClass, deployment, null); Set<Type> types = fooBean.getTypes(); // Foo, AbstractList<String>, AbstractCollection<String>, List<String>, Collection<String>, Iterable<String>, Object assertEquals(7, types.size()); assertTrue(types.contains(Type.create(fooName, Kind.CLASS))); assertTrue(types.contains(ParameterizedType.create(name(AbstractList.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null))); assertTrue(types.contains( ParameterizedType.create(name(List.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null))); assertTrue(types.contains(ParameterizedType.create(name(Collection.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null))); assertTrue(types.contains(ParameterizedType.create(name(AbstractCollection.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null))); assertTrue(types.contains(ParameterizedType.create(name(Iterable.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null))); }
Example #25
Source File: SchemaBuilder.java From smallrye-graphql with Apache License 2.0 | 5 votes |
private <T> void createAndAddToSchema(ReferenceType referenceType, Creator creator, Consumer<T> consumer) { while (!referenceCreator.values(referenceType).isEmpty()) { Reference reference = referenceCreator.values(referenceType).poll(); ClassInfo classInfo = ScanningContext.getIndex().getClassByName(DotName.createSimple(reference.getClassName())); consumer.accept((T) creator.create(classInfo)); } }
Example #26
Source File: AdvertisingMetadataProcessor.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void process() { Collection<AnnotationInstance> annos = index.getAnnotations(DotName.createSimple(Advertise.class.getName())); Collection<AnnotationInstance> repeatingAnnos = index.getAnnotations(DotName.createSimple(Advertises.class.getName())); Stream.concat(annos.stream(), repeatingAnnos .stream() .flatMap(anno -> Stream.of(anno.value().asNestedArray()))) .forEach(anno -> advertise(archive, anno)); }
Example #27
Source File: MethodValidatedAnnotationsTransformer.java From quarkus with Apache License 2.0 | 5 votes |
@Override public void transform(TransformationContext transformationContext) { MethodInfo method = transformationContext.getTarget().asMethod(); if (requiresValidation(method)) { if (isJaxrsMethod(method)) { transformationContext.transform().add(DotName.createSimple(JaxrsEndPointValidated.class.getName())).done(); } else { transformationContext.transform().add(DotName.createSimple(MethodValidated.class.getName())).done(); } } }
Example #28
Source File: Annotations.java From smallrye-graphql with Apache License 2.0 | 5 votes |
private static Map<DotName, AnnotationInstance> getTypeUseAnnotations(org.jboss.jandex.Type type) { if (type != null) { return getAnnotationsWithFilter(type, Annotations.DATE_FORMAT, Annotations.NUMBER_FORMAT); } return Collections.EMPTY_MAP; }
Example #29
Source File: JpaJandexScavenger.java From quarkus with Apache License 2.0 | 5 votes |
private static void enlistExplicitClasses(IndexView index, JpaEntitiesBuildItem domainObjectCollector, Set<String> enumTypeCollector, Set<String> javaTypeCollector, List<String> managedClassNames, Set<DotName> unindexedClasses) { for (String className : managedClassNames) { DotName dotName = DotName.createSimple(className); boolean isInIndex = index.getClassByName(dotName) != null; if (!isInIndex) { unindexedClasses.add(dotName); } addClassHierarchyToReflectiveList(index, domainObjectCollector, enumTypeCollector, javaTypeCollector, dotName, unindexedClasses); } }
Example #30
Source File: TypeCreator.java From smallrye-graphql with Apache License 2.0 | 5 votes |
private void addInterfaces(Type type, ClassInfo classInfo) { List<DotName> interfaceNames = classInfo.interfaceNames(); for (DotName interfaceName : interfaceNames) { // Ignore java interfaces (like Serializable) if (!interfaceName.toString().startsWith(JAVA_DOT)) { ClassInfo interfaceInfo = ScanningContext.getIndex().getClassByName(interfaceName); if (interfaceInfo != null) { Reference interfaceRef = referenceCreator.createReference(Direction.OUT, interfaceInfo); type.addInterface(interfaceRef); } } } }