Java Code Examples for org.jboss.jandex.AnnotationInstance#create()

The following examples show how to use org.jboss.jandex.AnnotationInstance#create() . 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: TemplateDataBuilder.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public AnnotationInstance build() {
    AnnotationValue ignoreValue;
    if (ignores.isEmpty()) {
        ignoreValue = AnnotationValue.createArrayValue(ValueResolverGenerator.IGNORE, new AnnotationValue[] {});
    } else {
        AnnotationValue[] values = new AnnotationValue[ignores.size()];
        for (int i = 0; i < ignores.size(); i++) {
            values[i] = AnnotationValue.createStringValue(ValueResolverGenerator.IGNORE + i, ignores.get(i));
        }
        ignoreValue = AnnotationValue.createArrayValue(ValueResolverGenerator.IGNORE, values);
    }
    AnnotationValue propertiesValue = AnnotationValue.createBooleanValue(ValueResolverGenerator.PROPERTIES, properties);
    AnnotationValue ignoreSuperclassesValue = AnnotationValue.createBooleanValue(ValueResolverGenerator.IGNORE_SUPERCLASSES,
            ignoreSuperclasses);
    return AnnotationInstance.create(ValueResolverGenerator.TEMPLATE_DATA, null,
            new AnnotationValue[] { ignoreValue, propertiesValue, ignoreSuperclassesValue });
}
 
Example 2
Source File: AnnotationTestCase.java    From gizmo with Apache License 2.0 5 votes vote down vote up
private void addAnnotationWithAnnotationValueArray(AnnotatedElement element) {
    AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(MyArrayAnnotation.class.getName()), null,
            new AnnotationValue[] {
                    AnnotationValue.createArrayValue("value",
                            new AnnotationValue[] {
                                    AnnotationValue.createStringValue("value", "test")
                            }
                    )
            }
    );
    element.addAnnotation(annotation);
}
 
Example 3
Source File: JandexUtilTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testRefValueWithHttpUrl() {
    String ref = "https://www.example.com/openapi";
    AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(""),
            null,
            Arrays.asList(AnnotationValue.createStringValue("ref", ref)));
    String outRef = JandexUtil.refValue(annotation, RefType.Link);
    assertEquals(ref, outRef);
}
 
Example 4
Source File: JandexUtilTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testRefValueWithRelativeUrl() {
    String ref = "./additional-schemas.json";
    AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(""),
            null,
            Arrays.asList(AnnotationValue.createStringValue("ref", ref)));
    String outRef = JandexUtil.refValue(annotation, RefType.Link);
    assertEquals(ref, outRef);
}
 
Example 5
Source File: JandexUtilTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testRefValueWithValidLinkName() {
    String ref = "L1nk.T0_Something-Useful";
    AnnotationInstance annotation = AnnotationInstance.create(DotName.createSimple(""),
            null,
            Arrays.asList(AnnotationValue.createStringValue("ref", ref)));
    String outRef = JandexUtil.refValue(annotation, RefType.Link);
    assertEquals("#/components/links/L1nk.T0_Something-Useful", outRef);
}
 
Example 6
Source File: FunctionScannerBuildStep.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private AnnotationInstance createTypedAnnotationInstance(ClassInfo clazz) {
    return AnnotationInstance.create(DotNames.TYPED, clazz,
            new AnnotationValue[] { AnnotationValue.createArrayValue("value",
                    new AnnotationValue[] { AnnotationValue.createClassValue("value",
                            Type.create(clazz.name(), org.jboss.jandex.Type.Kind.CLASS)) }) });
}
 
Example 7
Source File: SpringScheduledProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
void processSpringScheduledAnnotation(BuildProducer<ScheduledBusinessMethodItem> scheduledBusinessMethods,
        BeanInfo bean, MethodInfo method, List<AnnotationInstance> scheduledAnnotations) {
    List<AnnotationInstance> schedules = new ArrayList<>();
    if (scheduledAnnotations != null) {
        for (AnnotationInstance scheduledAnnotation : scheduledAnnotations) {
            List<AnnotationValue> springAnnotationValues = scheduledAnnotation.values();
            List<AnnotationValue> confValues = new ArrayList<>();
            if (!springAnnotationValues.isEmpty()) {
                if (annotationsValuesContain(springAnnotationValues, "fixedRate")
                        || annotationsValuesContain(springAnnotationValues, "fixedRateString")) {
                    confValues.add(buildEveryParam(springAnnotationValues));
                    if (annotationsValuesContain(springAnnotationValues, "initialDelay")
                            || annotationsValuesContain(springAnnotationValues, "initialDelayString")) {
                        confValues.addAll(buildDelayParams(springAnnotationValues));
                    }

                } else if (annotationsValuesContain(springAnnotationValues, "fixedDelay")
                        || annotationsValuesContain(springAnnotationValues, "fixedDelayString")) {
                    throw new IllegalArgumentException(
                            "Invalid @Scheduled method '" + method.name()
                                    + "': 'fixedDelay' not supported");
                } else if (annotationsValuesContain(springAnnotationValues, "cron")) {
                    if (annotationsValuesContain(springAnnotationValues, "initialDelay")) {
                        throw new IllegalArgumentException(
                                "Invalid @Scheduled method '" + method.name()
                                        + "': 'initialDelay' not supported for cron triggers");
                    }
                    confValues.add(buildCronParam(springAnnotationValues));
                }

            }
            AnnotationInstance regularAnnotationInstance = AnnotationInstance.create(QUARKUS_SCHEDULED,
                    scheduledAnnotation.target(), confValues);
            schedules.add(regularAnnotationInstance);
        }
        if (schedules != null) {
            scheduledBusinessMethods.produce(new ScheduledBusinessMethodItem(bean, method, schedules));
            LOGGER.debugf("Found scheduled business method %s declared on %s", method, bean);
        }
    }
}
 
Example 8
Source File: CacheAnnotationsTransformer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private AnnotationInstance createBinding(Class<?> bindingClass, AnnotationTarget target, AnnotationValue... values) {
    return AnnotationInstance.create(DotName.createSimple(bindingClass.getName()), target, values);
}
 
Example 9
Source File: ResteasyServerCommonProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private AnnotationInstance createTypedAnnotationInstance(ClassInfo clazz) {
    return AnnotationInstance.create(DotNames.TYPED, clazz,
            new AnnotationValue[] { AnnotationValue.createArrayValue("value",
                    new AnnotationValue[] { AnnotationValue.createClassValue("value",
                            Type.create(clazz.name(), org.jboss.jandex.Type.Kind.CLASS)) }) });
}