diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java index 7e8af20..e6ccd41 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java @@ -46,11 +46,11 @@ import java.util.*; @SuppressWarnings({ "unused" }) public class EventHelper { /** - * Contains all precomputed event listeners. + * Contains all cached event listeners. * * @since 1-alpha0 */ - private static final HashMap<@NotNull Class, LinkedList<@NotNull Method>> precomputedEventListeners = new HashMap<>(); + private static final HashMap<@NotNull Class, LinkedList<@NotNull Method>> cachedEventListeners = new HashMap<>(); /** * Constructor. @@ -72,10 +72,10 @@ public class EventHelper { } /** - * Returns all annotated methods. + * Returns all event listeners. * * @param clazz event class - * @param forceScanning forces the method to ignore precomputed event listeners + * @param forceScanning forces the method to ignore cached event listeners, not recommended * @return list of annotated methods * @since 1-alpha0 */ @@ -83,7 +83,7 @@ public class EventHelper { public static LinkedList getAnnotatedMethods(@NotNull Class clazz, boolean forceScanning) { LinkedList methods = new LinkedList<>(); - if (forceScanning || !precomputedEventListeners.containsKey(clazz) || EngineConfiguration.getInstance().isOptimizeEvents()) { + if (forceScanning || !cachedEventListeners.containsKey(clazz) || EngineConfiguration.getInstance().isOptimizeEvents()) { // Scan entire classpath through Reflections library Reflections reflections = new Reflections( new ConfigurationBuilder() @@ -102,7 +102,7 @@ public class EventHelper { // Sort 'methods' linked list methods.sort(Comparator.comparing(method0 -> method0.getAnnotation(EventListener.class).priority())); } else - methods = precomputedEventListeners.get(clazz); + methods = cachedEventListeners.get(clazz); return methods; } @@ -137,37 +137,37 @@ public class EventHelper { /** * Precomputes all event listeners listening on some event. - * Will recompute all event listeners if the specified event is already precomputed. + * Will recompute all event listeners if the specified event is already cached. * - * @param clazz event class to (p)recompute, set to {@code null} to recompute all precomputed events + * @param clazz event class to (p)recompute, set to {@code null} to recompute all cached events * @since 1-alpha0 */ public static void precomputeEventListeners(@Nullable Class clazz) { if (EngineConfiguration.getInstance().isOptimizeEvents()) return; if (clazz == null) - for (Class event : precomputedEventListeners.keySet()) + for (Class event : cachedEventListeners.keySet()) precomputeEventListeners(event); else { LinkedList<@NotNull Method> annotatedMethods = getAnnotatedMethods(clazz); - if (precomputedEventListeners.containsKey(clazz)) - precomputedEventListeners.replace(clazz, annotatedMethods); + if (cachedEventListeners.containsKey(clazz)) + cachedEventListeners.replace(clazz, annotatedMethods); else - precomputedEventListeners.put(clazz, annotatedMethods); + cachedEventListeners.put(clazz, annotatedMethods); } } /** - * Unloads precomputed event listeners. + * Removes events from the event listener cache. * - * @param clazz event class to remove precomputed event listeners for, set to {@code null} to remove all precomputed event listeners + * @param clazz event class to remove cached event listeners for, set to {@code null} to remove all cached event listeners * @since 1-alpha0 */ public static void removePrecomputedEventListeners(@Nullable Class clazz) { if (clazz == null) - precomputedEventListeners.clear(); + cachedEventListeners.clear(); else - precomputedEventListeners.remove(clazz); + cachedEventListeners.remove(clazz); } }