aboutsummaryrefslogtreecommitdiffstats
path: root/pf4j
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2024-02-03 22:29:31 +0200
committerDecebal Suiu <decebal.suiu@gmail.com>2024-02-03 22:29:31 +0200
commitd351e52ab4db778593538a616bc684c3d830c889 (patch)
treea202037981cb8418864ee5021021565b0319714a /pf4j
parenta33c7b084a429ce9d8b2c12495f697e40b0f2006 (diff)
downloadpf4j-d351e52ab4db778593538a616bc684c3d830c889.tar.gz
pf4j-d351e52ab4db778593538a616bc684c3d830c889.zip
Add more javadoc, fix warnings
Diffstat (limited to 'pf4j')
-rw-r--r--pf4j/src/main/java/org/pf4j/DependencyResolver.java46
1 files changed, 33 insertions, 13 deletions
diff --git a/pf4j/src/main/java/org/pf4j/DependencyResolver.java b/pf4j/src/main/java/org/pf4j/DependencyResolver.java
index 7960a46..092b58a 100644
--- a/pf4j/src/main/java/org/pf4j/DependencyResolver.java
+++ b/pf4j/src/main/java/org/pf4j/DependencyResolver.java
@@ -31,7 +31,7 @@ import java.util.Map;
* The {@code Result} class contains nice information about the result of resolve operation (if it's a cyclic dependency,
* they are not found dependencies, they are dependencies with wrong version).
* This class is very useful for if-else scenarios.
- *
+ * <p>
* Only some attributes (pluginId, dependencies and pluginVersion) from {@link PluginDescriptor} are used in
* the process of {@code resolve} operation.
*
@@ -41,7 +41,7 @@ public class DependencyResolver {
private static final Logger log = LoggerFactory.getLogger(DependencyResolver.class);
- private VersionManager versionManager;
+ private final VersionManager versionManager;
private DirectedGraph<String> dependenciesGraph; // the value is 'pluginId'
private DirectedGraph<String> dependentsGraph; // the value is 'pluginId'
@@ -51,6 +51,12 @@ public class DependencyResolver {
this.versionManager = versionManager;
}
+ /**
+ * Resolve the dependencies for the given plugins.
+ *
+ * @param plugins the list of plugins
+ * @return a {@link Result} object
+ */
public Result resolve(List<PluginDescriptor> plugins) {
// create graphs
dependenciesGraph = new DirectedGraph<>();
@@ -128,9 +134,9 @@ public class DependencyResolver {
/**
* Check if an existing version of dependency is compatible with the required version (from plugin descriptor).
*
- * @param requiredVersion
- * @param existingVersion
- * @return
+ * @param requiredVersion the required version
+ * @param existingVersion the existing version
+ * @return {@code true} if the existing version is compatible with the required version, {@code false} otherwise
*/
protected boolean checkDependencyVersion(String requiredVersion, String existingVersion) {
return versionManager.checkVersionConstraint(existingVersion, requiredVersion);
@@ -180,12 +186,15 @@ public class DependencyResolver {
"' for plugin '" + dependent.getPluginId() + "'");
}
+ /**
+ * The result of the {@link #resolve(List)} operation.
+ */
public static class Result {
private boolean cyclicDependency;
- private List<String> notFoundDependencies; // value is "pluginId"
- private List<String> sortedPlugins; // value is "pluginId"
- private List<WrongDependencyVersion> wrongVersionDependencies;
+ private final List<String> notFoundDependencies; // value is "pluginId"
+ private final List<String> sortedPlugins; // value is "pluginId"
+ private final List<WrongDependencyVersion> wrongVersionDependencies;
Result(List<String> sortedPlugins) {
if (sortedPlugins == null) {
@@ -201,6 +210,8 @@ public class DependencyResolver {
/**
* Returns true is a cyclic dependency was detected.
+ *
+ * @return true is a cyclic dependency was detected
*/
public boolean hasCyclicDependency() {
return cyclicDependency;
@@ -208,6 +219,8 @@ public class DependencyResolver {
/**
* Returns a list with dependencies required that were not found.
+ *
+ * @return a list with dependencies required that were not found
*/
public List<String> getNotFoundDependencies() {
return notFoundDependencies;
@@ -215,6 +228,8 @@ public class DependencyResolver {
/**
* Returns a list with dependencies with wrong version.
+ *
+ * @return a list with dependencies with wrong version
*/
public List<WrongDependencyVersion> getWrongVersionDependencies() {
return wrongVersionDependencies;
@@ -222,6 +237,8 @@ public class DependencyResolver {
/**
* Get the list of plugins in dependency sorted order.
+ *
+ * @return the list of plugins in dependency sorted order
*/
public List<String> getSortedPlugins() {
return sortedPlugins;
@@ -237,12 +254,15 @@ public class DependencyResolver {
}
+ /**
+ * Represents a wrong dependency version.
+ */
public static class WrongDependencyVersion {
- private String dependencyId; // value is "pluginId"
- private String dependentId; // value is "pluginId"
- private String existingVersion;
- private String requiredVersion;
+ private final String dependencyId; // value is "pluginId"
+ private final String dependentId; // value is "pluginId"
+ private final String existingVersion;
+ private final String requiredVersion;
WrongDependencyVersion(String dependencyId, String dependentId, String existingVersion, String requiredVersion) {
this.dependencyId = dependencyId;
@@ -294,7 +314,7 @@ public class DependencyResolver {
*/
public static class DependenciesNotFoundException extends PluginRuntimeException {
- private List<String> dependencies;
+ private final List<String> dependencies;
public DependenciesNotFoundException(List<String> dependencies) {
super("Dependencies '{}' not found", dependencies);