1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 23:40:08 -08:00

Change the cache search function to be more generic.

This commit is contained in:
Danila Fedorin 2017-08-03 10:03:13 -07:00
parent 9b71f9aaf4
commit 819fff6391

View File

@ -82,10 +82,10 @@ public class PluginManager {
* @param <T> the type of element being search * @param <T> the type of element being search
* @return the retrieved element, or null if it was not found. * @return the retrieved element, or null if it was not found.
*/ */
private static <T> T searchCached(Collection<Plugin> plugins, Map<String, T> cache, private static <T, K> T searchCached(Collection<Plugin> plugins, Map<K, T> cache,
java.util.function.Function<Plugin, Set<String>> setFunction, java.util.function.Function<Plugin, Set<K>> setFunction,
java.util.function.BiFunction<Plugin, String, T> getFunction, java.util.function.BiFunction<Plugin, K, T> getFunction,
String name) { K name) {
if (cache.containsKey(name)) return cache.get(name); if (cache.containsKey(name)) return cache.get(name);
T loadedValue = null; T loadedValue = null;