log.debug("Finding extensions for extension point '{}'", type.getName());
readIndexFiles();
- List<ExtensionWrapper<T>> result = new ArrayList<ExtensionWrapper<T>>();
+ List<ExtensionWrapper<T>> result = new ArrayList<>();
for (Map.Entry<String, Set<String>> entry : entries.entrySet()) {
String pluginId = entry.getKey();
descriptor.setOrdinal(extension.ordinal());
descriptor.setExtensionClass(extensionClass);
- ExtensionWrapper extensionWrapper = new ExtensionWrapper<T>(descriptor);
+ ExtensionWrapper extensionWrapper = new ExtensionWrapper<>(descriptor);
extensionWrapper.setExtensionFactory(extensionFactory);
result.add(extensionWrapper);
log.debug("Added extension '{}' with ordinal {}", className, extension.ordinal());
return entries;
}
- entries = new LinkedHashMap<String, Set<String>>();
+ entries = new LinkedHashMap<>();
readClasspathIndexFiles();
readPluginsIndexFiles();
private void readClasspathIndexFiles() {
log.debug("Reading extensions index files from classpath");
- Set<String> bucket = new HashSet<String>();
+ Set<String> bucket = new HashSet<>();
try {
Enumeration<URL> urls = getClass().getClassLoader().getResources(ExtensionsIndexer.EXTENSIONS_RESOURCE);
while (urls.hasMoreElements()) {
for (PluginWrapper plugin : plugins) {
String pluginId = plugin.getDescriptor().getPluginId();
log.debug("Reading extensions index file for plugin '{}'", pluginId);
- Set<String> bucket = new HashSet<String>();
+ Set<String> bucket = new HashSet<>();
try {
URL url = plugin.getPluginClassLoader().getResource(ExtensionsIndexer.EXTENSIONS_RESOURCE);
@Override
public List<PluginWrapper> getPlugins() {
- return new ArrayList<PluginWrapper>(plugins.values());
+ return new ArrayList<>(plugins.values());
}
@Override
public List<PluginWrapper> getPlugins(PluginState pluginState) {
- List<PluginWrapper> plugins= new ArrayList<PluginWrapper>();
+ List<PluginWrapper> plugins= new ArrayList<>();
for (PluginWrapper plugin : getPlugins()) {
if (pluginState.equals(plugin.getPluginState())) {
plugins.add(plugin);
}
// check for no plugins
- List<FileFilter> filterList = new ArrayList<FileFilter>();
+ List<FileFilter> filterList = new ArrayList<>();
filterList.add(new DirectoryFileFilter());
filterList.add(new NotFileFilter(createHiddenPluginFilter()));
FileFilter pluginsFilter = new AndFileFilter(filterList);
@Override
public <T> List<T> getExtensions(Class<T> type) {
List<ExtensionWrapper<T>> extensionsWrapper = extensionFinder.find(type);
- List<T> extensions = new ArrayList<T>(extensionsWrapper.size());
+ List<T> extensions = new ArrayList<>(extensionsWrapper.size());
for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
extensions.add(extensionWrapper.getExtension());
}
}
private void initialize() {
- plugins = new HashMap<String, PluginWrapper>();
- pluginClassLoaders = new HashMap<String, PluginClassLoader>();
- pathToIdMap = new HashMap<String, String>();
- unresolvedPlugins = new ArrayList<PluginWrapper>();
- resolvedPlugins = new ArrayList<PluginWrapper>();
- startedPlugins = new ArrayList<PluginWrapper>();
-
- pluginStateListeners = new ArrayList<PluginStateListener>();
+ 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());
private final File pluginsDirectory;
- private List<String> enabledPlugins = new ArrayList<String>();
- private List<String> disabledPlugins = new ArrayList<String>();
+ private List<String> enabledPlugins = new ArrayList<>();
+ private List<String> disabledPlugins = new ArrayList<>();
public DefaultPluginStatusProvider(File pluginsDirectory) {
this.pluginsDirectory = pluginsDirectory;
* Get the list of plugins in dependency sorted order.
*/
public List<PluginWrapper> getSortedPlugins() throws PluginException {
- DirectedGraph<String> graph = new DirectedGraph<String>();
+ DirectedGraph<String> graph = new DirectedGraph<>();
for (PluginWrapper pluginWrapper : plugins) {
PluginDescriptor descriptor = pluginWrapper.getDescriptor();
String pluginId = descriptor.getPluginId();
}
log.debug("Plugins order: {}", pluginsId);
- List<PluginWrapper> sortedPlugins = new ArrayList<PluginWrapper>();
+ List<PluginWrapper> sortedPlugins = new ArrayList<>();
for (String pluginId : pluginsId) {
sortedPlugins.add(getPlugin(pluginId));
}
public static final String EXTENSIONS_RESOURCE = "META-INF/extensions.idx";
- private List<TypeElement> extensions = new ArrayList<TypeElement>();
+ private List<TypeElement> extensions = new ArrayList<>();
@Override
public SourceVersion getSupportedSourceVersion() {
@Override
public Set<String> getSupportedAnnotationTypes() {
- Set<String> annotationTypes = new HashSet<String>();
+ Set<String> annotationTypes = new HashSet<>();
annotationTypes.add(Extension.class.getName());
return annotationTypes;
}
private void write() {
- Set<String> entries = new HashSet<String>();
+ Set<String> entries = new HashSet<>();
for (TypeElement typeElement : extensions) {
entries.add(processingEnv.getElementUtils().getBinaryName(typeElement).toString());
}
protected List<String> libDirectories;
public PluginClasspath() {
- classesDirectories = new ArrayList<String>();
- libDirectories = new ArrayList<String>();
+ classesDirectories = new ArrayList<>();
+ libDirectories = new ArrayList<>();
addResources();
}
public PluginDescriptor() {
requires = Version.ZERO;
- dependencies = new ArrayList<PluginDependency>();
+ dependencies = new ArrayList<>();
}
/**
if (dependencies.isEmpty()) {
this.dependencies = Collections.emptyList();
} else {
- this.dependencies = new ArrayList<PluginDependency>();
+ this.dependencies = new ArrayList<>();
String[] tokens = dependencies.split(",");
for (String dependency : tokens) {
dependency = dependency.trim();
File file = new File(pluginRepository, libDirectory).getAbsoluteFile();
// collect all jars from current lib directory in jars variable
- Vector<File> jars = new Vector<File>();
+ Vector<File> jars = new Vector<>();
getJars(jars, file);
for (File jar : jars) {
try {
private final String name;
- private static final Map<String, RuntimeMode> map = new HashMap<String, RuntimeMode>();
+ private static final Map<String, RuntimeMode> map = new HashMap<>();
static {
for (RuntimeMode mode : RuntimeMode.values()) {
private List<FileFilter> fileFilters;
public AndFileFilter() {
- this.fileFilters = new ArrayList<FileFilter>();
+ this.fileFilters = new ArrayList<>();
}
public AndFileFilter(List<FileFilter> fileFilters) {
- this.fileFilters = new ArrayList<FileFilter>(fileFilters);
+ this.fileFilters = new ArrayList<>(fileFilters);
}
public void addFileFilter(FileFilter fileFilter) {
}
public void setFileFilters(List<FileFilter> fileFilters) {
- this.fileFilters = new ArrayList<FileFilter>(fileFilters);
+ this.fileFilters = new ArrayList<>(fileFilters);
}
@Override
return false;
}
- for (Iterator<FileFilter> iter = this.fileFilters.iterator(); iter.hasNext();) {
- FileFilter fileFilter = (FileFilter) iter.next();
+ for (FileFilter fileFilter : this.fileFilters) {
if (!fileFilter.accept(file)) {
return false;
}
*/
public class CompoundClassLoader extends ClassLoader {
- private Set<ClassLoader> loaders = new HashSet<ClassLoader>();
+ private Set<ClassLoader> loaders = new HashSet<>();
public void addLoader(ClassLoader loader) {
loaders.add(loader);
@Override
protected Enumeration<URL> findResources(String name) throws IOException {
- List<URL> resources = new ArrayList<URL>();
+ List<URL> resources = new ArrayList<>();
for (ClassLoader loader : loaders) {
resources.addAll(Collections.list(loader.getResources(name)));
}
* of an array of lists, a Map is used to map each vertex to its list of
* adjacent vertices.
*/
- private Map<V, List<V>> neighbors = new HashMap<V, List<V>>();
+ private Map<V, List<V>> neighbors = new HashMap<>();
/**
* Add a vertex to the graph. Nothing happens if vertex is already in graph.
* Report (as a Map) the out-degree of each vertex.
*/
public Map<V, Integer> outDegree() {
- Map<V, Integer> result = new HashMap<V, Integer>();
+ Map<V, Integer> result = new HashMap<>();
for (V vertex : neighbors.keySet()) {
result.put(vertex, neighbors.get(vertex).size());
}
* Report (as a Map) the in-degree of each vertex.
*/
public Map<V,Integer> inDegree() {
- Map<V, Integer> result = new HashMap<V, Integer>();
+ Map<V, Integer> result = new HashMap<>();
for (V vertex : neighbors.keySet()) {
result.put(vertex, 0); // all in-degrees are 0
}
Map<V, Integer> degree = inDegree();
// determine all vertices with zero in-degree
- Stack<V> zeroVertices = new Stack<V>(); // stack as good as any here
+ Stack<V> zeroVertices = new Stack<>(); // stack as good as any here
for (V v : degree.keySet()) {
if (degree.get(v) == 0) {
zeroVertices.push(v);
}
// determine the topological order
- List<V> result = new ArrayList<V>();
+ List<V> 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
return Collections.emptyList();
}
- List<String> lines = new ArrayList<String>();
+ List<String> lines = new ArrayList<>();
BufferedReader reader = null;
try {