diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2019-12-20 22:59:22 +0200 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2019-12-20 22:59:22 +0200 |
commit | 77fb6914b47a93b805baae8a6ff819f686367144 (patch) | |
tree | 6e8c81e2807a07b4cc5d6fbb7631fde2bde9a29b /pf4j/src/main/java/org | |
parent | b011f59c632a42c9d4b8abb239fd767a115e056d (diff) | |
download | pf4j-77fb6914b47a93b805baae8a6ff819f686367144.tar.gz pf4j-77fb6914b47a93b805baae8a6ff819f686367144.zip |
Improve readability
Diffstat (limited to 'pf4j/src/main/java/org')
-rw-r--r-- | pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java b/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java index 2faf143..797fe04 100644 --- a/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java +++ b/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java @@ -172,6 +172,34 @@ public class ExtensionAnnotationProcessor extends AbstractProcessor { return storage; } + private void processExtensionElement(Element element) { + // check if @Extension is put on class and not on method or constructor + if (!(element instanceof TypeElement)) { + error(element, "Put annotation only on classes (no methods, no fields)"); + return; + } + + // check if class extends/implements an extension point + if (!ignoreExtensionPoint && !isExtension(element.asType())) { + error(element, "%s is not an extension (it doesn't implement ExtensionPoint)", element); + return; + } + + TypeElement extensionElement = (TypeElement) element; + List<TypeElement> extensionPointElements = findExtensionPoints(extensionElement); + if (extensionPointElements.isEmpty()) { + error(element, "No extension points found for extension %s", extensionElement); + return; + } + + String extension = getBinaryName(extensionElement); + for (TypeElement extensionPointElement : extensionPointElements) { + String extensionPoint = getBinaryName(extensionPointElement); + Set<String> extensionPoints = extensions.computeIfAbsent(extensionPoint, k -> new TreeSet<>()); + extensionPoints.add(extension); + } + } + @SuppressWarnings("unchecked") private List<TypeElement> findExtensionPoints(TypeElement extensionElement) { List<TypeElement> extensionPointElements = new ArrayList<>(); @@ -263,34 +291,6 @@ public class ExtensionAnnotationProcessor extends AbstractProcessor { System.getProperty(IGNORE_EXTENSION_POINT) != null; } - private void processExtensionElement(Element element) { - // check if @Extension is put on class and not on method or constructor - if (!(element instanceof TypeElement)) { - error(element, "Put annotation only on classes (no methods, no fields)"); - return; - } - - // check if class extends/implements an extension point - if (!ignoreExtensionPoint && !isExtension(element.asType())) { - error(element, "%s is not an extension (it doesn't implement ExtensionPoint)", element); - return; - } - - TypeElement extensionElement = (TypeElement) element; - List<TypeElement> extensionPointElements = findExtensionPoints(extensionElement); - if (extensionPointElements.isEmpty()) { - error(element, "No extension points found for extension %s", extensionElement); - return; - } - - String extension = getBinaryName(extensionElement); - for (TypeElement extensionPointElement : extensionPointElements) { - String extensionPoint = getBinaryName(extensionPointElement); - Set<String> extensionPoints = extensions.computeIfAbsent(extensionPoint, k -> new TreeSet<>()); - extensionPoints.add(extension); - } - } - private TypeElement getElement(TypeMirror typeMirror) { return (TypeElement) ((DeclaredType) typeMirror).asElement(); } |