Java Code Examples for javax.lang.model.element.Element#getAnnotationsByType()
The following examples show how to use
javax.lang.model.element.Element#getAnnotationsByType() .
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: PluginChecker.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 2
Source File: PluginChecker.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 3
Source File: PluginChecker.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 4
Source File: PluginChecker.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 5
Source File: PluginChecker.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 6
Source File: MatchProcessor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Build up the type table to be used during parsing of the MatchRule. */ private void processMatchableNode(Element element) { if (!processedMatchableNode.contains(element)) { try { processedMatchableNode.add(element); AnnotationMirror mirror = findAnnotationMirror(element, matchableNodesTypeMirror); if (mirror == null) { mirror = findAnnotationMirror(element, matchableNodeTypeMirror); } if (mirror == null) { return; } TypeElement topDeclaringType = topDeclaringType(element); List<AnnotationMirror> mirrors = null; if (typeUtils().isSameType(mirror.getAnnotationType(), matchableNodesTypeMirror)) { // Unpack the mirrors for a repeatable annotation mirrors = getAnnotationValueList(AnnotationMirror.class, mirror, "value"); } int i = 0; for (MatchableNode matchableNode : element.getAnnotationsByType(MatchableNode.class)) { processMatchableNode(element, topDeclaringType, matchableNode, mirrors != null ? mirrors.get(i++) : mirror); } } catch (Throwable t) { reportExceptionThrow(element, t); } } }
Example 7
Source File: PluginChecker.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 8
Source File: PluginChecker.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 9
Source File: PluginChecker.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 10
Source File: PluginChecker.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 11
Source File: PluginChecker.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 12
Source File: PluginChecker.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 13
Source File: PluginChecker.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Processes @Require annotations and checks that Device meets requirements. * * {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { for (Require req : el.getAnnotationsByType(Require.class)) { //for every Require annotation checks if device has module of required version. Integer version = device.getSupportedModules().get(req.value()); if (version == null || version < req.minVersion() || version > req.maxVersion()) { //if module is optional then show only warning not error if (req.optional()) { processingEnv.getMessager() .printMessage(Diagnostic.Kind.WARNING, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module." + " This module is optional." + " So plugin will work but miss" + " some functionality" : "has " + version + " version of that module")); } else { processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Plugin [" + el + "] requires " + req + "\n but device " + (version == null ? "doesn't have such module" : "has " + version + " version of that module")); } } } return true; } return false; }
Example 14
Source File: ActionProcessor.java From syndesis with Apache License 2.0 | 4 votes |
/** * Add action properties to the global properties. */ private void addActionProperties(ObjectNode root, Element element) throws InvocationTargetException, IllegalAccessException { Annotation[] annotations = element.getAnnotationsByType(propertyAnnotationClass); for (int i = 0; i < annotations.length; i++) { Annotation annotation = annotations[i]; ObjectNode propertyNode = mapper.createObjectNode(); gatherProperties(propertyNode, annotation); if (element.getKind() == ElementKind.FIELD) { VariableElement field = (VariableElement)element; TypeMirror typeMirror = field.asType(); TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(typeMirror.toString()); String javaType = typeMirror.toString(); String type = propertyNode.get("type").asText(); final boolean doesntHaveEnums = !propertyNode.has("enums"); final boolean typeIsEnum = typeElement != null && typeElement.getKind() == ElementKind.ENUM; if (doesntHaveEnums && typeIsEnum) { // don't auto detect enum if enums are set through // annotations for (Element enumElement : typeElement.getEnclosedElements()) { if (enumElement.getKind() == ElementKind.ENUM_CONSTANT) { ObjectNode enumNode = mapper.createObjectNode(); writeIfNotEmpty(enumNode, "label", enumElement.toString()); writeIfNotEmpty(enumNode, "value", enumElement.toString()); propertyNode.withArray("enums").add(enumNode); } } javaType = String.class.getName(); type = String.class.getName(); } if (type == null || "".equals(type.trim())){ if (String.class.getName().equals(type)) { type = "string"; } else if (Boolean.class.getName().equals(type)) { type = "boolean"; } else if (Integer.class.getName().equals(type)) { type = "int"; } else if (Float.class.getName().equals(type)) { type = "float"; } else if (Double.class.getName().equals(type)) { type = "double"; } } writeIfNotEmpty(propertyNode, "javaType", javaType); writeIfNotEmpty(propertyNode, "type", type); } root.withArray("properties").add(propertyNode); } }
Example 15
Source File: Resolver.java From Chimera with MIT License | 4 votes |
@Override public <A extends Annotation> A[] all(Element element, Class<A> annotation) { return element.getAnnotationsByType(annotation); }