From 36f77cc63d99ee041aeaac280e74e8900abb3367 Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Wed, 1 Feb 2023 21:10:19 +0200 Subject: [PATCH] Fix some warnings (javadoc, pom, sonar) --- .../org/pf4j/AbstractExtensionFinder.java | 3 +- .../java/org/pf4j/AbstractPluginManager.java | 12 +++---- .../java/org/pf4j/ClassLoadingStrategy.java | 12 +++---- .../main/java/org/pf4j/util/ClassUtils.java | 32 ++----------------- .../main/java/org/pf4j/util/StringUtils.java | 2 ++ pom.xml | 6 +++- 6 files changed, 22 insertions(+), 45 deletions(-) diff --git a/pf4j/src/main/java/org/pf4j/AbstractExtensionFinder.java b/pf4j/src/main/java/org/pf4j/AbstractExtensionFinder.java index 8288ddc..998a29d 100644 --- a/pf4j/src/main/java/org/pf4j/AbstractExtensionFinder.java +++ b/pf4j/src/main/java/org/pf4j/AbstractExtensionFinder.java @@ -41,7 +41,7 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin protected volatile Map extensionInfos; // cache extension infos by class name protected Boolean checkForExtensionDependencies = null; - public AbstractExtensionFinder(PluginManager pluginManager) { + protected AbstractExtensionFinder(PluginManager pluginManager) { this.pluginManager = pluginManager; } @@ -50,7 +50,6 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin public abstract Map> readClasspathStorages(); @Override - @SuppressWarnings("unchecked") public List> find(Class type) { log.debug("Finding extensions of extension point '{}'", type.getName()); Map> entries = getEntries(); diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java index d57b12e..f56a94f 100644 --- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java +++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java @@ -113,7 +113,7 @@ public abstract class AbstractPluginManager implements PluginManager { /** * The plugins roots are supplied as comma-separated list by {@code System.getProperty("pf4j.pluginsDir", "plugins")}. */ - public AbstractPluginManager() { + protected AbstractPluginManager() { initialize(); } @@ -122,7 +122,7 @@ public abstract class AbstractPluginManager implements PluginManager { * * @param pluginsRoots the roots to search for plugins */ - public AbstractPluginManager(Path... pluginsRoots) { + protected AbstractPluginManager(Path... pluginsRoots) { this(Arrays.asList(pluginsRoots)); } @@ -131,7 +131,7 @@ public abstract class AbstractPluginManager implements PluginManager { * * @param pluginsRoots the roots to search for plugins */ - public AbstractPluginManager(List pluginsRoots) { + protected AbstractPluginManager(List pluginsRoots) { this.pluginsRoots.addAll(pluginsRoots); initialize(); @@ -877,10 +877,10 @@ public abstract class AbstractPluginManager implements PluginManager { return pluginWrapper; } - + /** * creates the plugin wrapper. override this if you want to prevent plugins having full access to the plugin manager - * + * * @return */ protected PluginWrapper createPluginWrapper(PluginDescriptor pluginDescriptor, Path pluginPath, ClassLoader pluginClassLoader) { @@ -933,7 +933,7 @@ public abstract class AbstractPluginManager implements PluginManager { /** * Set to true to allow requires expression to be exactly x.y.z. * The default is false, meaning that using an exact version x.y.z will - * implicitly mean the same as >=x.y.z + * implicitly mean the same as >=x.y.z * * @param exactVersionAllowed set to true or false */ diff --git a/pf4j/src/main/java/org/pf4j/ClassLoadingStrategy.java b/pf4j/src/main/java/org/pf4j/ClassLoadingStrategy.java index 7ef3952..3dfe425 100644 --- a/pf4j/src/main/java/org/pf4j/ClassLoadingStrategy.java +++ b/pf4j/src/main/java/org/pf4j/ClassLoadingStrategy.java @@ -30,32 +30,32 @@ import java.util.List; public class ClassLoadingStrategy { /** - * application(parent) -> plugin -> dependencies + * application(parent) -> plugin -> dependencies */ public static final ClassLoadingStrategy APD = new ClassLoadingStrategy(Arrays.asList(Source.APPLICATION, Source.PLUGIN, Source.DEPENDENCIES)); /** - * application(parent) -> dependencies -> plugin + * application(parent) -> dependencies -> plugin */ public static final ClassLoadingStrategy ADP = new ClassLoadingStrategy(Arrays.asList(Source.APPLICATION, Source.DEPENDENCIES, Source.PLUGIN)); /** - * plugin -> application(parent) -> dependencies + * plugin -> application(parent) -> dependencies */ public static final ClassLoadingStrategy PAD = new ClassLoadingStrategy(Arrays.asList(Source.PLUGIN, Source.APPLICATION, Source.DEPENDENCIES)); /** - * dependencies -> application(parent) -> plugin + * dependencies -> application(parent) -> plugin */ public static final ClassLoadingStrategy DAP = new ClassLoadingStrategy(Arrays.asList(Source.DEPENDENCIES, Source.APPLICATION, Source.PLUGIN)); /** - * dependencies -> plugin -> application(parent) + * dependencies -> plugin -> application(parent) */ public static final ClassLoadingStrategy DPA = new ClassLoadingStrategy(Arrays.asList(Source.DEPENDENCIES, Source.PLUGIN, Source.APPLICATION)); /** - * plugin -> dependencies -> application(parent) + * plugin -> dependencies -> application(parent) */ public static final ClassLoadingStrategy PDA = new ClassLoadingStrategy(Arrays.asList(Source.PLUGIN, Source.DEPENDENCIES, Source.APPLICATION)); diff --git a/pf4j/src/main/java/org/pf4j/util/ClassUtils.java b/pf4j/src/main/java/org/pf4j/util/ClassUtils.java index 97daa27..c64ea47 100644 --- a/pf4j/src/main/java/org/pf4j/util/ClassUtils.java +++ b/pf4j/src/main/java/org/pf4j/util/ClassUtils.java @@ -28,6 +28,8 @@ import java.util.Map; */ public class ClassUtils { + private ClassUtils() {} + public static List getAllInterfacesNames(Class aClass) { return toString(getAllInterfaces(aClass)); } @@ -56,26 +58,6 @@ public class ClassUtils { return list; } - /* - public static List getAllAbstractClassesNames(Class aClass) { - return toString(getAllInterfaces(aClass)); - } - - public static List getAllAbstractClasses(Class aClass) { - List> list = new ArrayList<>(); - - Class superclass = aClass.getSuperclass(); - while (superclass != null) { - if (Modifier.isAbstract(superclass.getModifiers())) { - list.add(superclass); - } - superclass = superclass.getSuperclass(); - } - - return list; - } - */ - /** * Get a certain annotation of a {@link TypeElement}. * See stackoverflow.com for more information. @@ -96,13 +78,6 @@ public class ClassUtils { return null; } - /* - public static Element getAnnotationMirrorElement(TypeElement typeElement, Class annotationClass) { - AnnotationMirror annotationMirror = getAnnotationMirror(typeElement, annotationClass); - return annotationMirror != null ? annotationMirror.getAnnotationType().asElement() : null; - } - */ - /** * Get a certain parameter of an {@link AnnotationMirror}. * See stackoverflow.com for more information. @@ -139,9 +114,6 @@ public class ClassUtils { /** * Uses {@link Class#getSimpleName()} to convert from {@link Class} to {@link String}. - * - * @param classes - * @return */ private static List toString(List> classes) { List list = new ArrayList<>(); diff --git a/pf4j/src/main/java/org/pf4j/util/StringUtils.java b/pf4j/src/main/java/org/pf4j/util/StringUtils.java index 72087ca..aa84ff4 100644 --- a/pf4j/src/main/java/org/pf4j/util/StringUtils.java +++ b/pf4j/src/main/java/org/pf4j/util/StringUtils.java @@ -20,6 +20,8 @@ package org.pf4j.util; */ public class StringUtils { + private StringUtils() {} + public static boolean isNullOrEmpty(String str) { return (str == null) || str.isEmpty(); } diff --git a/pom.xml b/pom.xml index f19d170..97e2c30 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt repo @@ -66,6 +66,7 @@ + org.apache.maven.plugins maven-compiler-plugin 3.8.0 @@ -74,11 +75,13 @@ + org.apache.maven.plugins maven-surefire-plugin 2.22.1 + org.apache.maven.plugins maven-jar-plugin 2.6 @@ -149,6 +152,7 @@ + org.apache.maven.plugins maven-jar-plugin