From: Decebal Suiu Date: Fri, 5 Jun 2015 14:50:29 +0000 (+0300) Subject: convert existing generics to diamond syntax X-Git-Tag: release-0.10.0~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aee82c92b003743bf8d15b029a8d172083839360;p=pf4j.git convert existing generics to diamond syntax --- diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java index 758b0c3..2df14ae 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java @@ -53,7 +53,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe log.debug("Finding extensions for extension point '{}'", type.getName()); readIndexFiles(); - List> result = new ArrayList>(); + List> result = new ArrayList<>(); for (Map.Entry> entry : entries.entrySet()) { String pluginId = entry.getKey(); @@ -84,7 +84,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe descriptor.setOrdinal(extension.ordinal()); descriptor.setExtensionClass(extensionClass); - ExtensionWrapper extensionWrapper = new ExtensionWrapper(descriptor); + ExtensionWrapper extensionWrapper = new ExtensionWrapper<>(descriptor); extensionWrapper.setExtensionFactory(extensionFactory); result.add(extensionWrapper); log.debug("Added extension '{}' with ordinal {}", className, extension.ordinal()); @@ -128,7 +128,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe return entries; } - entries = new LinkedHashMap>(); + entries = new LinkedHashMap<>(); readClasspathIndexFiles(); readPluginsIndexFiles(); @@ -139,7 +139,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe private void readClasspathIndexFiles() { log.debug("Reading extensions index files from classpath"); - Set bucket = new HashSet(); + Set bucket = new HashSet<>(); try { Enumeration urls = getClass().getClassLoader().getResources(ExtensionsIndexer.EXTENSIONS_RESOURCE); while (urls.hasMoreElements()) { @@ -171,7 +171,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe for (PluginWrapper plugin : plugins) { String pluginId = plugin.getDescriptor().getPluginId(); log.debug("Reading extensions index file for plugin '{}'", pluginId); - Set bucket = new HashSet(); + Set bucket = new HashSet<>(); try { URL url = plugin.getPluginClassLoader().getResource(ExtensionsIndexer.EXTENSIONS_RESOURCE); diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java index 9ee3e7a..df73ad5 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java @@ -129,12 +129,12 @@ public class DefaultPluginManager implements PluginManager { @Override public List getPlugins() { - return new ArrayList(plugins.values()); + return new ArrayList<>(plugins.values()); } @Override public List getPlugins(PluginState pluginState) { - List plugins= new ArrayList(); + List plugins= new ArrayList<>(); for (PluginWrapper plugin : getPlugins()) { if (pluginState.equals(plugin.getPluginState())) { plugins.add(plugin); @@ -354,7 +354,7 @@ public class DefaultPluginManager implements PluginManager { } // check for no plugins - List filterList = new ArrayList(); + List filterList = new ArrayList<>(); filterList.add(new DirectoryFileFilter()); filterList.add(new NotFileFilter(createHiddenPluginFilter())); FileFilter pluginsFilter = new AndFileFilter(filterList); @@ -527,7 +527,7 @@ public class DefaultPluginManager implements PluginManager { @Override public List getExtensions(Class type) { List> extensionsWrapper = extensionFinder.find(type); - List extensions = new ArrayList(extensionsWrapper.size()); + List extensions = new ArrayList<>(extensionsWrapper.size()); for (ExtensionWrapper extensionWrapper : extensionsWrapper) { extensions.add(extensionWrapper.getExtension()); } @@ -696,14 +696,14 @@ public class DefaultPluginManager implements PluginManager { } private void initialize() { - plugins = new HashMap(); - pluginClassLoaders = new HashMap(); - pathToIdMap = new HashMap(); - unresolvedPlugins = new ArrayList(); - resolvedPlugins = new ArrayList(); - startedPlugins = new ArrayList(); - - pluginStateListeners = new ArrayList(); + plugins = new HashMap<>(); + pluginClassLoaders = new HashMap<>(); + pathToIdMap = new HashMap<>(); + unresolvedPlugins = new ArrayList<>(); + resolvedPlugins = new ArrayList<>(); + startedPlugins = new ArrayList<>(); + + pluginStateListeners = new ArrayList<>(); log.info("PF4J version {} in '{}' mode", getVersion(), getRuntimeMode()); diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java index 7554aaa..89a359f 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java @@ -32,8 +32,8 @@ public class DefaultPluginStatusProvider implements PluginStatusProvider { private final File pluginsDirectory; - private List enabledPlugins = new ArrayList(); - private List disabledPlugins = new ArrayList(); + private List enabledPlugins = new ArrayList<>(); + private List disabledPlugins = new ArrayList<>(); public DefaultPluginStatusProvider(File pluginsDirectory) { this.pluginsDirectory = pluginsDirectory; diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java index 885928b..2eaf473 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java @@ -37,7 +37,7 @@ class DependencyResolver { * Get the list of plugins in dependency sorted order. */ public List getSortedPlugins() throws PluginException { - DirectedGraph graph = new DirectedGraph(); + DirectedGraph graph = new DirectedGraph<>(); for (PluginWrapper pluginWrapper : plugins) { PluginDescriptor descriptor = pluginWrapper.getDescriptor(); String pluginId = descriptor.getPluginId(); @@ -59,7 +59,7 @@ class DependencyResolver { } log.debug("Plugins order: {}", pluginsId); - List sortedPlugins = new ArrayList(); + List sortedPlugins = new ArrayList<>(); for (String pluginId : pluginsId) { sortedPlugins.add(getPlugin(pluginId)); } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java index eec6c95..df36064 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java @@ -38,7 +38,7 @@ public class ExtensionsIndexer extends AbstractProcessor { public static final String EXTENSIONS_RESOURCE = "META-INF/extensions.idx"; - private List extensions = new ArrayList(); + private List extensions = new ArrayList<>(); @Override public SourceVersion getSupportedSourceVersion() { @@ -47,7 +47,7 @@ public class ExtensionsIndexer extends AbstractProcessor { @Override public Set getSupportedAnnotationTypes() { - Set annotationTypes = new HashSet(); + Set annotationTypes = new HashSet<>(); annotationTypes.add(Extension.class.getName()); return annotationTypes; @@ -83,7 +83,7 @@ public class ExtensionsIndexer extends AbstractProcessor { } private void write() { - Set entries = new HashSet(); + Set entries = new HashSet<>(); for (TypeElement typeElement : extensions) { entries.add(processingEnv.getElementUtils().getBinaryName(typeElement).toString()); } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClasspath.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClasspath.java index 541bb0a..c8d9b41 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClasspath.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClasspath.java @@ -32,8 +32,8 @@ public class PluginClasspath { protected List libDirectories; public PluginClasspath() { - classesDirectories = new ArrayList(); - libDirectories = new ArrayList(); + classesDirectories = new ArrayList<>(); + libDirectories = new ArrayList<>(); addResources(); } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java index f456f7c..0721474 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java @@ -34,7 +34,7 @@ public class PluginDescriptor { public PluginDescriptor() { requires = Version.ZERO; - dependencies = new ArrayList(); + dependencies = new ArrayList<>(); } /** @@ -125,7 +125,7 @@ public class PluginDescriptor { if (dependencies.isEmpty()) { this.dependencies = Collections.emptyList(); } else { - this.dependencies = new ArrayList(); + this.dependencies = new ArrayList<>(); String[] tokens = dependencies.split(","); for (String dependency : tokens) { dependency = dependency.trim(); diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java index 03e7683..e4433f4 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java @@ -106,7 +106,7 @@ class PluginLoader { File file = new File(pluginRepository, libDirectory).getAbsoluteFile(); // collect all jars from current lib directory in jars variable - Vector jars = new Vector(); + Vector jars = new Vector<>(); getJars(jars, file); for (File jar : jars) { try { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java b/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java index fa57b2a..51b8ffe 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java @@ -26,7 +26,7 @@ public enum RuntimeMode { private final String name; - private static final Map map = new HashMap(); + private static final Map map = new HashMap<>(); static { for (RuntimeMode mode : RuntimeMode.values()) { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java index b06c1d9..f5fb6ec 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java @@ -34,11 +34,11 @@ public class AndFileFilter implements FileFilter { private List fileFilters; public AndFileFilter() { - this.fileFilters = new ArrayList(); + this.fileFilters = new ArrayList<>(); } public AndFileFilter(List fileFilters) { - this.fileFilters = new ArrayList(fileFilters); + this.fileFilters = new ArrayList<>(fileFilters); } public void addFileFilter(FileFilter fileFilter) { @@ -54,7 +54,7 @@ public class AndFileFilter implements FileFilter { } public void setFileFilters(List fileFilters) { - this.fileFilters = new ArrayList(fileFilters); + this.fileFilters = new ArrayList<>(fileFilters); } @Override @@ -63,8 +63,7 @@ public class AndFileFilter implements FileFilter { return false; } - for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { - FileFilter fileFilter = (FileFilter) iter.next(); + for (FileFilter fileFilter : this.fileFilters) { if (!fileFilter.accept(file)) { return false; } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/CompoundClassLoader.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/CompoundClassLoader.java index 426b2a3..c26049c 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/CompoundClassLoader.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/CompoundClassLoader.java @@ -28,7 +28,7 @@ import java.util.Set; */ public class CompoundClassLoader extends ClassLoader { - private Set loaders = new HashSet(); + private Set loaders = new HashSet<>(); public void addLoader(ClassLoader loader) { loaders.add(loader); @@ -65,7 +65,7 @@ public class CompoundClassLoader extends ClassLoader { @Override protected Enumeration findResources(String name) throws IOException { - List resources = new ArrayList(); + List resources = new ArrayList<>(); for (ClassLoader loader : loaders) { resources.addAll(Collections.list(loader.getResources(name))); } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java index 06d8986..58b8d6c 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java @@ -29,7 +29,7 @@ public class DirectedGraph { * of an array of lists, a Map is used to map each vertex to its list of * adjacent vertices. */ - private Map> neighbors = new HashMap>(); + private Map> neighbors = new HashMap<>(); /** * Add a vertex to the graph. Nothing happens if vertex is already in graph. @@ -73,7 +73,7 @@ public class DirectedGraph { * Report (as a Map) the out-degree of each vertex. */ public Map outDegree() { - Map result = new HashMap(); + Map result = new HashMap<>(); for (V vertex : neighbors.keySet()) { result.put(vertex, neighbors.get(vertex).size()); } @@ -85,7 +85,7 @@ public class DirectedGraph { * Report (as a Map) the in-degree of each vertex. */ public Map inDegree() { - Map result = new HashMap(); + Map result = new HashMap<>(); for (V vertex : neighbors.keySet()) { result.put(vertex, 0); // all in-degrees are 0 } @@ -105,7 +105,7 @@ public class DirectedGraph { Map degree = inDegree(); // determine all vertices with zero in-degree - Stack zeroVertices = new Stack(); // stack as good as any here + Stack zeroVertices = new Stack<>(); // stack as good as any here for (V v : degree.keySet()) { if (degree.get(v) == 0) { zeroVertices.push(v); @@ -113,7 +113,7 @@ public class DirectedGraph { } // determine the topological order - List result = new ArrayList(); + List result = new ArrayList<>(); while (!zeroVertices.isEmpty()) { V vertex = zeroVertices.pop(); // choose a vertex with zero in-degree result.add(vertex); // vertex 'v' is next in topological order diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/FileUtils.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/FileUtils.java index 2ac97db..c3c81b0 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/FileUtils.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/FileUtils.java @@ -28,7 +28,7 @@ public class FileUtils { return Collections.emptyList(); } - List lines = new ArrayList(); + List lines = new ArrayList<>(); BufferedReader reader = null; try {