From: Decebal Suiu Date: Mon, 1 Apr 2019 19:19:05 +0000 (+0300) Subject: Fix warnings X-Git-Tag: release-3.0.0~2^2~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6addff34e21dbcd784d38f8b8c5c6259a42b2613;p=pf4j.git Fix warnings --- diff --git a/pf4j/src/main/java/org/pf4j/BasePluginRepository.java b/pf4j/src/main/java/org/pf4j/BasePluginRepository.java index a353756..381059c 100644 --- a/pf4j/src/main/java/org/pf4j/BasePluginRepository.java +++ b/pf4j/src/main/java/org/pf4j/BasePluginRepository.java @@ -48,14 +48,7 @@ public class BasePluginRepository implements PluginRepository { this.filter = filter; // last modified file is first - this.comparator = new Comparator() { - - @Override - public int compare(File o1, File o2) { - return (int) (o2.lastModified() - o1.lastModified()); - } - - }; + this.comparator = (o1, o2) -> (int) (o2.lastModified() - o1.lastModified()); } public void setFilter(FileFilter filter) { diff --git a/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java b/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java index 74cd0f3..6401f21 100644 --- a/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java +++ b/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java @@ -78,7 +78,7 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder { } } - protected Path getManifestPath(Path pluginPath) throws PluginException { + protected Path getManifestPath(Path pluginPath) { if (Files.isDirectory(pluginPath)) { // legacy (the path is something like "classes/META-INF/MANIFEST.MF") return FileUtils.findFile(pluginPath,"MANIFEST.MF"); diff --git a/pf4j/src/main/java/org/pf4j/PluginWrapper.java b/pf4j/src/main/java/org/pf4j/PluginWrapper.java index c7d93ca..209afb9 100644 --- a/pf4j/src/main/java/org/pf4j/PluginWrapper.java +++ b/pf4j/src/main/java/org/pf4j/PluginWrapper.java @@ -120,11 +120,9 @@ public class PluginWrapper { } PluginWrapper other = (PluginWrapper) obj; - if (!descriptor.getPluginId().equals(other.descriptor.getPluginId())) { - return false; - } - return true; + return descriptor.getPluginId().equals(other.descriptor.getPluginId()); + } @Override diff --git a/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java b/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java index e0f3513..55bbbc2 100644 --- a/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java +++ b/pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java @@ -109,11 +109,7 @@ public class ExtensionAnnotationProcessor extends AbstractProcessor { String extension = getBinaryName(extensionElement); for (TypeElement extensionPointElement : extensionPointElements) { String extensionPoint = getBinaryName(extensionPointElement); - Set extensionPoints = extensions.get(extensionPoint); - if (extensionPoints == null) { - extensionPoints = new TreeSet<>(); - extensions.put(extensionPoint, extensionPoints); - } + Set extensionPoints = extensions.computeIfAbsent(extensionPoint, k -> new TreeSet<>()); extensionPoints.add(extension); } } diff --git a/pf4j/src/main/java/org/pf4j/util/AndFileFilter.java b/pf4j/src/main/java/org/pf4j/util/AndFileFilter.java index cc74da4..76a17ec 100644 --- a/pf4j/src/main/java/org/pf4j/util/AndFileFilter.java +++ b/pf4j/src/main/java/org/pf4j/util/AndFileFilter.java @@ -23,11 +23,9 @@ import java.util.Collections; import java.util.List; /** - * This filter providing conditional AND logic across a list of - * file filters. This filter returns true if all filters in the - * list return true. Otherwise, it returns false. - * Checking of the file filter list stops when the first filter returns - * false. + * This filter providing conditional AND logic across a list of file filters. + * This filter returns {@code true} if all filters in the list return {@code true}. Otherwise, it returns {@code false}. + * Checking of the file filter list stops when the first filter returns {@code false}. * * @author Decebal Suiu */ @@ -37,7 +35,7 @@ public class AndFileFilter implements FileFilter { private List fileFilters; public AndFileFilter() { - this(new ArrayList()); + this(new ArrayList<>()); } public AndFileFilter(FileFilter... fileFilters) { @@ -68,7 +66,7 @@ public class AndFileFilter implements FileFilter { @Override public boolean accept(File file) { - if (this.fileFilters.size() == 0) { + if (this.fileFilters.isEmpty()) { return false; } diff --git a/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java b/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java index 076d67c..1163f91 100644 --- a/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java +++ b/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java @@ -44,7 +44,7 @@ public class DirectedGraph { return; } - neighbors.put(vertex, new ArrayList()); + neighbors.put(vertex, new ArrayList<>()); } /** @@ -85,7 +85,7 @@ public class DirectedGraph { } public List getNeighbors(V vertex) { - return containsVertex(vertex) ? neighbors.get(vertex) : new ArrayList(); + return containsVertex(vertex) ? neighbors.get(vertex) : new ArrayList<>(); } /** @@ -101,7 +101,7 @@ public class DirectedGraph { } /** - * Report (as a Map) the in-degree (the number of head ends adjacent to a vertex) of each vertex. + * Report (as a {@link Map}) the in-degree (the number of head ends adjacent to a vertex) of each vertex. */ public Map inDegree() { Map result = new HashMap<>(); @@ -181,9 +181,9 @@ public class DirectedGraph { */ @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (V vertex : neighbors.keySet()) { - sb.append("\n " + vertex + " -> " + neighbors.get(vertex)); + sb.append("\n ").append(vertex).append(" -> ").append(neighbors.get(vertex)); } return sb.toString(); diff --git a/pf4j/src/main/java/org/pf4j/util/OrFileFilter.java b/pf4j/src/main/java/org/pf4j/util/OrFileFilter.java index fccfb7b..5798249 100644 --- a/pf4j/src/main/java/org/pf4j/util/OrFileFilter.java +++ b/pf4j/src/main/java/org/pf4j/util/OrFileFilter.java @@ -23,11 +23,9 @@ import java.util.Collections; import java.util.List; /** - * This filter providing conditional OR logic across a list of - * file filters. This filter returns true if one filter in the - * list return true. Otherwise, it returns false. - * Checking of the file filter list stops when the first filter returns - * true. + * This filter providing conditional OR logic across a list of file filters. + * This filter returns {@code true} if one filter in the list return {@code true}. Otherwise, it returns {@code false}. + * Checking of the file filter list stops when the first filter returns {@code true}. * * @author Decebal Suiu */ @@ -37,7 +35,7 @@ public class OrFileFilter implements FileFilter { private List fileFilters; public OrFileFilter() { - this(new ArrayList()); + this(new ArrayList<>()); } public OrFileFilter(FileFilter... fileFilters) { @@ -68,7 +66,7 @@ public class OrFileFilter implements FileFilter { @Override public boolean accept(File file) { - if (this.fileFilters.size() == 0) { + if (this.fileFilters.isEmpty()) { return true; }