From 99541f3be81f351a6e9fc4df7f4145b99238a651 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Fri, 2 Apr 2021 07:31:26 -0700 Subject: [PATCH 1/5] Reformat bracket style --- .../com/clubobsidian/trident/Cancelable.java | 25 +- .../java/com/clubobsidian/trident/Event.java | 22 +- .../com/clubobsidian/trident/EventBus.java | 237 ++++---- .../clubobsidian/trident/EventHandler.java | 8 +- .../clubobsidian/trident/EventPriority.java | 65 +- .../clubobsidian/trident/MethodExecutor.java | 73 ++- .../clubobsidian/trident/event/DeadEvent.java | 32 +- .../eventbus/javassist/JavassistEventBus.java | 215 +++---- .../reflection/ReflectionEventBus.java | 13 +- .../reflection/ReflectionMethodExecutor.java | 35 +- .../clubobsidian/trident/util/ClassUtil.java | 46 +- .../trident/util/EventDoublyLinkedList.java | 269 ++++----- .../clubobsidian/trident/util/EventNode.java | 101 ++-- .../trident/test/DeadEventTest.java | 53 +- .../trident/test/EventBusTest.java | 209 +++---- .../test/EventDoublyLinkedListTest.java | 567 ++++++++---------- .../trident/test/EventPriorityTest.java | 29 +- .../clubobsidian/trident/test/EventTest.java | 18 +- .../trident/test/IgnoreCanceledTest.java | 28 +- .../trident/test/JavaAssistEventBusTest.java | 111 ++-- .../trident/test/MultiThreadingTest.java | 95 ++- .../trident/test/OtherEventBusTest.java | 20 +- .../trident/test/ReflectionEventBusTest.java | 9 +- .../trident/test/ReflectionMiscEventTest.java | 75 +-- .../clubobsidian/trident/test/UtilTest.java | 28 +- .../test/impl/TestCancelableEvent.java | 22 +- .../test/impl/TestDeadEventListener.java | 34 +- .../trident/test/impl/TestEvent.java | 5 +- .../trident/test/impl/TestEventBus.java | 13 +- .../trident/test/impl/TestEventSuper.java | 5 +- .../trident/test/impl/TestListener.java | 138 ++--- .../trident/test/impl/TestListenerIgnore.java | 46 +- .../trident/test/impl/TestMethodExecutor.java | 20 +- .../trident/test/impl/TestOrderEvent.java | 3 +- .../test/impl/TestWrongArgumentListener.java | 43 +- 35 files changed, 1249 insertions(+), 1463 deletions(-) diff --git a/src/main/java/com/clubobsidian/trident/Cancelable.java b/src/main/java/com/clubobsidian/trident/Cancelable.java index ac8bcde..684c962 100644 --- a/src/main/java/com/clubobsidian/trident/Cancelable.java +++ b/src/main/java/com/clubobsidian/trident/Cancelable.java @@ -16,22 +16,23 @@ package com.clubobsidian.trident; /** - * Interface to implement Cancelable. + * Interface to implement Cancelable. * Events should implement this interface * if the event should be able to be cancelled. - * + * * @author virustotalop */ public interface Cancelable { - /** - * Returns if the event is cancelled. - * @return if the event is cancelled - */ - public boolean isCanceled(); - - /** - * Set whether or not for an event to be cancelled. - */ - public void setCanceled(boolean cancel); + /** + * Returns if the event is cancelled. + * + * @return if the event is cancelled + */ + public boolean isCanceled(); + + /** + * Set whether or not for an event to be cancelled. + */ + public void setCanceled(boolean cancel); } diff --git a/src/main/java/com/clubobsidian/trident/Event.java b/src/main/java/com/clubobsidian/trident/Event.java index b6c209f..d6c82fb 100644 --- a/src/main/java/com/clubobsidian/trident/Event.java +++ b/src/main/java/com/clubobsidian/trident/Event.java @@ -18,18 +18,18 @@ /** * Superclass of all events. Events should * extend this class. - * + * * @author virustotalop */ public abstract class Event { - - /** - * Uses reflection getClass().getSimpleName() to return - * the name of the event class. - * @return name of the event - */ - public String getName() - { - return this.getClass().getSimpleName(); - } + + /** + * Uses reflection getClass().getSimpleName() to return + * the name of the event class. + * + * @return name of the event + */ + public String getName() { + return this.getClass().getSimpleName(); + } } diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index 09ef21d..72878fc 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -15,6 +15,11 @@ */ package com.clubobsidian.trident; +import com.clubobsidian.trident.event.DeadEvent; +import com.clubobsidian.trident.util.ClassUtil; +import com.clubobsidian.trident.util.EventDoublyLinkedList; +import com.clubobsidian.trident.util.EventNode; + import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; @@ -22,140 +27,114 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; -import com.clubobsidian.trident.event.DeadEvent; -import com.clubobsidian.trident.util.ClassUtil; -import com.clubobsidian.trident.util.EventDoublyLinkedList; -import com.clubobsidian.trident.util.EventNode; - /** * Abstract class for implementing EventBus * classes. For an example see @see com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus - * + * * @author virustotalop */ public abstract class EventBus { - private Map> registeredEventListeners; - private Map, EventDoublyLinkedList> registeredExecutors; - public EventBus() - { - this.registeredEventListeners = new ConcurrentHashMap<>(); - this.registeredExecutors = new ConcurrentHashMap<>(); - } - - /** - * @param event Event to call - * @return if the event was called - */ - public boolean callEvent(final Event event) - { - EventDoublyLinkedList executors = this.registeredExecutors.get(event.getClass()); - - if(executors == null) - { - if(!(event instanceof DeadEvent)) - { - this.callEvent(new DeadEvent(event)); - } - return false; - } - - boolean ran = false; - EventNode node = executors.getHead(); - if(node != null) - { - ran = true; - } - while(node != null) - { - MethodExecutor executor = node.getData(); - if(event instanceof Cancelable) - { - Cancelable cancelable = (Cancelable) event; - if(cancelable.isCanceled() && executor.isIgnoringCanceled()) - { - node = node.getNext(); - continue; - } - } - executor.execute(event); - node = node.getNext(); - } - - return ran; - } - - /** - * @param listener listener to be registered - * @return if the listener was registered - */ - public boolean registerEvents(final Object listener) - { - if(listener == null) - { - return false; - } - else if(this.registeredEventListeners.keySet().contains(listener)) - { - return false; - } - - Class cl = listener.getClass(); - for(Method method : cl.getDeclaredMethods()) - { - for(EventHandler handler : method.getAnnotationsByType(EventHandler.class)) - { - if(method.getParameters().length == 1) - { - Class eventClass = method.getParameterTypes()[0]; - if(ClassUtil.hasEventSuperClass(eventClass)) - { - if(this.registeredExecutors.get(eventClass) == null) - { - this.registeredExecutors.put(eventClass, new EventDoublyLinkedList()); - } - if(this.registeredEventListeners.get(listener) == null) - { - this.registeredEventListeners.put(listener, new ConcurrentLinkedQueue<>()); - } - - boolean ignoreCanceled = handler.ignoreCanceled(); - MethodExecutor executor = this.createMethodExecutor(listener, method, ignoreCanceled); - - if(executor == null) - return false; - - this.registeredExecutors.get(eventClass).insert(executor, handler.priority()); - this.registeredEventListeners.get(listener).add(executor); - } - } - } - } - return true; - } - - protected abstract MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled); - - /** - * - * @param listener listener to be unregistered - * @return if the listener was unregistered - */ - public boolean unregisterEvents(Object listener) - { - Queue executors = this.registeredEventListeners.remove(listener); - if(executors == null) - return false; - - for(EventDoublyLinkedList list : this.registeredExecutors.values()) - { - Iterator it = executors.iterator(); - while(it.hasNext()) - { - MethodExecutor executor = it.next(); - list.remove(executor); - } - } - return true; - } + private Map> registeredEventListeners; + private Map, EventDoublyLinkedList> registeredExecutors; + + public EventBus() { + this.registeredEventListeners = new ConcurrentHashMap<>(); + this.registeredExecutors = new ConcurrentHashMap<>(); + } + + /** + * @param event Event to call + * @return if the event was called + */ + public boolean callEvent(final Event event) { + EventDoublyLinkedList executors = this.registeredExecutors.get(event.getClass()); + + if (executors == null) { + if (!(event instanceof DeadEvent)) { + this.callEvent(new DeadEvent(event)); + } + return false; + } + + boolean ran = false; + EventNode node = executors.getHead(); + if (node != null) { + ran = true; + } + while (node != null) { + MethodExecutor executor = node.getData(); + if (event instanceof Cancelable) { + Cancelable cancelable = (Cancelable) event; + if (cancelable.isCanceled() && executor.isIgnoringCanceled()) { + node = node.getNext(); + continue; + } + } + executor.execute(event); + node = node.getNext(); + } + + return ran; + } + + /** + * @param listener listener to be registered + * @return if the listener was registered + */ + public boolean registerEvents(final Object listener) { + if (listener == null) { + return false; + } else if (this.registeredEventListeners.keySet().contains(listener)) { + return false; + } + + Class cl = listener.getClass(); + for (Method method : cl.getDeclaredMethods()) { + for (EventHandler handler : method.getAnnotationsByType(EventHandler.class)) { + if (method.getParameters().length == 1) { + Class eventClass = method.getParameterTypes()[0]; + if (ClassUtil.hasEventSuperClass(eventClass)) { + if (this.registeredExecutors.get(eventClass) == null) { + this.registeredExecutors.put(eventClass, new EventDoublyLinkedList()); + } + if (this.registeredEventListeners.get(listener) == null) { + this.registeredEventListeners.put(listener, new ConcurrentLinkedQueue<>()); + } + + boolean ignoreCanceled = handler.ignoreCanceled(); + MethodExecutor executor = this.createMethodExecutor(listener, method, ignoreCanceled); + + if (executor == null) + return false; + + this.registeredExecutors.get(eventClass).insert(executor, handler.priority()); + this.registeredEventListeners.get(listener).add(executor); + } + } + } + } + return true; + } + + protected abstract MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled); + + /** + * @param listener listener to be unregistered + * @return if the listener was unregistered + */ + public boolean unregisterEvents(Object listener) { + Queue executors = this.registeredEventListeners.remove(listener); + if (executors == null) + return false; + + for (EventDoublyLinkedList list : this.registeredExecutors.values()) { + Iterator it = executors.iterator(); + while (it.hasNext()) { + MethodExecutor executor = it.next(); + list.remove(executor); + } + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/EventHandler.java b/src/main/java/com/clubobsidian/trident/EventHandler.java index 984c9c7..89ff48f 100644 --- a/src/main/java/com/clubobsidian/trident/EventHandler.java +++ b/src/main/java/com/clubobsidian/trident/EventHandler.java @@ -25,14 +25,14 @@ * When methods are annotated in * listeners events are registered in * an {@code EventManager} instance. - * + * * @author virustotalop */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = ElementType.METHOD) public @interface EventHandler { - EventPriority priority() default EventPriority.NORMAL; - boolean ignoreCanceled() default false; - + EventPriority priority() default EventPriority.NORMAL; + boolean ignoreCanceled() default false; + } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/EventPriority.java b/src/main/java/com/clubobsidian/trident/EventPriority.java index 37384f1..4387eb5 100644 --- a/src/main/java/com/clubobsidian/trident/EventPriority.java +++ b/src/main/java/com/clubobsidian/trident/EventPriority.java @@ -18,42 +18,39 @@ /** * Enum representation of priority for registered events. * Default priority is {@link EventPriority#NORMAL} - * + * * @author virustotalop */ public enum EventPriority { - LOWEST(0), - LOW(1), - NORMAL(2), - HIGH(3), - HIGHEST(4), - MONITOR(5); - - private int value; - private EventPriority(final int value) - { - this.value = value; - } - - /** - * @return the integer representation of the underlying enum - */ - public int getValue() - { - return this.value; - } - - /** - * @param value the integer value of an eventpriority - * @return The EventPriority found by the given value - */ - public static EventPriority getByValue(final int value) - { - if(value < 0 || value >= EventPriority.values().length) - { - return null; - } - return EventPriority.values()[value]; - } + LOWEST(0), + LOW(1), + NORMAL(2), + HIGH(3), + HIGHEST(4), + MONITOR(5); + + private int value; + + private EventPriority(final int value) { + this.value = value; + } + + /** + * @return the integer representation of the underlying enum + */ + public int getValue() { + return this.value; + } + + /** + * @param value the integer value of an eventpriority + * @return The EventPriority found by the given value + */ + public static EventPriority getByValue(final int value) { + if (value < 0 || value >= EventPriority.values().length) { + return null; + } + return EventPriority.values()[value]; + } } diff --git a/src/main/java/com/clubobsidian/trident/MethodExecutor.java b/src/main/java/com/clubobsidian/trident/MethodExecutor.java index 8ab0be4..256ed36 100644 --- a/src/main/java/com/clubobsidian/trident/MethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/MethodExecutor.java @@ -21,47 +21,44 @@ * Abstract class for MethodExecutor implementations * to extend. {@link MethodExecutor#execute(Event)} * to be overridden in implementation classes. - * + * * @author virustotalop */ public abstract class MethodExecutor { - private Object listener; - private Method method; - private boolean ignoreCanceled; - public MethodExecutor(Object listener, Method method, boolean ignoreCanceled) - { - this.listener = listener; - this.method = method; - this.ignoreCanceled = ignoreCanceled; - } + private Object listener; + private Method method; + private boolean ignoreCanceled; - /** - * @return listener to execute events on - */ - public Object getListener() - { - return this.listener; - } - - /** - * @return method to execute - */ - public Method getMethod() - { - return this.method; - } - - /** - * @return whether or not the method executor is ignoring canceled - */ - public boolean isIgnoringCanceled() - { - return this.ignoreCanceled; - } - - /** - * @param event that is executed on the class listener - */ - public abstract void execute(Event event); + public MethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + this.listener = listener; + this.method = method; + this.ignoreCanceled = ignoreCanceled; + } + + /** + * @return listener to execute events on + */ + public Object getListener() { + return this.listener; + } + + /** + * @return method to execute + */ + public Method getMethod() { + return this.method; + } + + /** + * @return whether or not the method executor is ignoring canceled + */ + public boolean isIgnoringCanceled() { + return this.ignoreCanceled; + } + + /** + * @param event that is executed on the class listener + */ + public abstract void execute(Event event); } diff --git a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java index 37ee383..273579c 100644 --- a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java +++ b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java @@ -21,24 +21,24 @@ * Event that is called if an event is not * listened to by a listener. * Extends {@link Event} - * + * * @author virustotalop */ public class DeadEvent extends Event { - private Event event; - public DeadEvent(Event event) - { - this.event = event; - } - - /** - * Returns an event that was - * not fired. - * @return event not fired - */ - public Event getDeadEvent() - { - return this.event; - } + private Event event; + + public DeadEvent(Event event) { + this.event = event; + } + + /** + * Returns an event that was + * not fired. + * + * @return event not fired + */ + public Event getDeadEvent() { + return this.event; + } } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java index 3b5779c..1f15726 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java @@ -15,135 +15,110 @@ */ package com.clubobsidian.trident.eventbus.javassist; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicInteger; - import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.MethodExecutor; +import javassist.*; -import javassist.CannotCompileException; -import javassist.ClassClassPath; -import javassist.ClassPool; -import javassist.CtClass; -import javassist.CtMethod; -import javassist.CtNewMethod; -import javassist.LoaderClassPath; -import javassist.NotFoundException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; /** * {@inheritDoc} */ public class JavassistEventBus extends EventBus { - private static ConcurrentMap map; - - static - { - JavassistEventBus.map = new ConcurrentHashMap<>(); - } - - private ClassPool pool; - public JavassistEventBus() - { - this.pool = new ClassPool(true); - this.setupPool(); - } - - private void setupPool() - { - this.addClassToPool(Event.class); - } - - public ClassPool getClassPool() - { - return this.pool; - } - - @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) - { - return this.generateMethodExecutor(listener, method, ignoreCanceled); - } - - private MethodExecutor generateMethodExecutor(Object listener, final Method method, final boolean ignoreCanceled) - { - if(listener == null || method == null) - return null; - - try - { - ClassLoader classLoader = listener.getClass().getClassLoader(); - - Class listenerClass = Class.forName(listener.getClass().getName(), true, classLoader); - - this.addClassToPool(Event.class); - - LoaderClassPath loaderClassPath = new LoaderClassPath(classLoader); - - this.pool.insertClassPath(loaderClassPath); - this.addClassToPool(listenerClass); - - String callbackClassName = listener.getClass().getName() + method.getName(); - - AtomicInteger collision = map.get(callbackClassName); - int classNum = -1; - if(collision == null) - { - collision = new AtomicInteger(0); - classNum = 0; - JavassistEventBus.map.put(callbackClassName, collision); - } - else - { - classNum = collision.incrementAndGet(); - } - - callbackClassName += classNum; - - CtClass checkMethodExecutorClass = this.pool.getOrNull(callbackClassName); - if(checkMethodExecutorClass != null) - { - if(checkMethodExecutorClass.isFrozen()) - { - return null; - } - } - - CtClass methodExecutorClass = this.pool.makeClass(callbackClassName); - - - methodExecutorClass.setSuperclass(this.pool.get("com.clubobsidian.trident.MethodExecutor")); - - String eventType = method.getParameterTypes()[0].getName(); - String listenerType = listener.getClass().getName(); - - StringBuilder sb = new StringBuilder(); - sb.append("public void execute(" + Event.class.getName() + " event)"); - sb.append("{"); - sb.append(eventType + " ev = " + "((" + eventType + ") event);"); - sb.append("((" + listenerType + ")" + "this.getListener())." + method.getName() + "(ev);"); - sb.append("}"); - - CtMethod call = CtNewMethod.make(sb.toString(), methodExecutorClass); - methodExecutorClass.addMethod(call); - - Class cl = methodExecutorClass.toClass(classLoader, JavassistEventBus.class.getProtectionDomain()); - return (MethodExecutor) cl.getDeclaredConstructors()[0].newInstance(listener, method, ignoreCanceled); - } - catch (NotFoundException | CannotCompileException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException e) - { - e.printStackTrace(); + private static Map map = new ConcurrentHashMap<>(); + + private ClassPool pool; + + public JavassistEventBus() { + this.pool = new ClassPool(true); + this.setupPool(); + } + + private void setupPool() { + this.addClassToPool(Event.class); + } + + public ClassPool getClassPool() { + return this.pool; + } + + @Override + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + return this.generateMethodExecutor(listener, method, ignoreCanceled); + } + + private MethodExecutor generateMethodExecutor(Object listener, final Method method, final boolean ignoreCanceled) { + if (listener == null || method == null) { + return null; } - return null; - } - - private void addClassToPool(Class clazz) - { - ClassClassPath classClassPath = new ClassClassPath(clazz); - this.pool.insertClassPath(classClassPath); - } + + try { + ClassLoader classLoader = listener.getClass().getClassLoader(); + + Class listenerClass = Class.forName(listener.getClass().getName(), true, classLoader); + + this.addClassToPool(Event.class); + + LoaderClassPath loaderClassPath = new LoaderClassPath(classLoader); + + this.pool.insertClassPath(loaderClassPath); + this.addClassToPool(listenerClass); + + String callbackClassName = listener.getClass().getName() + method.getName(); + + AtomicInteger collision = map.get(callbackClassName); + int classNum = -1; + if (collision == null) { + collision = new AtomicInteger(0); + classNum = 0; + JavassistEventBus.map.put(callbackClassName, collision); + } else { + classNum = collision.incrementAndGet(); + } + + callbackClassName += classNum; + + CtClass checkMethodExecutorClass = this.pool.getOrNull(callbackClassName); + if (checkMethodExecutorClass != null) { + if (checkMethodExecutorClass.isFrozen()) { + return null; + } + } + + CtClass methodExecutorClass = this.pool.makeClass(callbackClassName); + + + methodExecutorClass.setSuperclass(this.pool.get("com.clubobsidian.trident.MethodExecutor")); + + String eventType = method.getParameterTypes()[0].getName(); + String listenerType = listener.getClass().getName(); + + StringBuilder sb = new StringBuilder(); + sb.append("public void execute(" + Event.class.getName() + " event)"); + sb.append("{"); + sb.append(eventType + " ev = " + "((" + eventType + ") event);"); + sb.append("((" + listenerType + ")" + "this.getListener())." + method.getName() + "(ev);"); + sb.append("}"); + + CtMethod call = CtNewMethod.make(sb.toString(), methodExecutorClass); + methodExecutorClass.addMethod(call); + + Class cl = methodExecutorClass.toClass(classLoader, JavassistEventBus.class.getProtectionDomain()); + return (MethodExecutor) cl.getDeclaredConstructors()[0].newInstance(listener, method, ignoreCanceled); + } catch (NotFoundException | CannotCompileException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException e) { + e.printStackTrace(); + } + return null; + } + + private void addClassToPool(Class clazz) { + ClassClassPath classClassPath = new ClassClassPath(clazz); + this.pool.insertClassPath(classClassPath); + } } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java index 971cae2..5e9effa 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java @@ -15,19 +15,18 @@ */ package com.clubobsidian.trident.eventbus.reflection; -import java.lang.reflect.Method; - import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.MethodExecutor; +import java.lang.reflect.Method; + /** * {@inheritDoc} */ public class ReflectionEventBus extends EventBus { - @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) - { - return new ReflectionMethodExecutor(listener, method, ignoreCanceled); - } + @Override + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + return new ReflectionMethodExecutor(listener, method, ignoreCanceled); + } } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java index dbba86a..b4dcc93 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java @@ -15,32 +15,27 @@ */ package com.clubobsidian.trident.eventbus.reflection; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import com.clubobsidian.trident.Event; import com.clubobsidian.trident.MethodExecutor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + /** * {@inheritDoc} */ public class ReflectionMethodExecutor extends MethodExecutor { - public ReflectionMethodExecutor(Object listener, Method method, boolean ignoreCanceled) - { - super(listener, method, ignoreCanceled); - } - - @Override - public void execute(final Event event) - { - try - { - this.getMethod().invoke(this.getListener(), event); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - e.printStackTrace(); - } - } + public ReflectionMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + super(listener, method, ignoreCanceled); + } + + @Override + public void execute(final Event event) { + try { + this.getMethod().invoke(this.getListener(), event); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/util/ClassUtil.java b/src/main/java/com/clubobsidian/trident/util/ClassUtil.java index f0f423c..cc3545c 100644 --- a/src/main/java/com/clubobsidian/trident/util/ClassUtil.java +++ b/src/main/java/com/clubobsidian/trident/util/ClassUtil.java @@ -19,33 +19,31 @@ /** * Utility class for class based operations. - * + * * @author virustotalop */ public final class ClassUtil { - private ClassUtil() {} + private ClassUtil() { + } - /** - * Checks to see if a given class has {@link Event} - * as a super class. Uses reflection to recursively - * call {@link Class#getSuperclass()} to check - * the super class. - * - * @param cl class to check for an event super class - * @return whether or not the given class has {@link Event} - * as a super class. - */ - public static boolean hasEventSuperClass(Class cl) - { - Class superClass = cl; - while((superClass = superClass.getSuperclass()) != null) - { - if(superClass == Event.class) - { - return true; - } - } - return false; - } + /** + * Checks to see if a given class has {@link Event} + * as a super class. Uses reflection to recursively + * call {@link Class#getSuperclass()} to check + * the super class. + * + * @param cl class to check for an event super class + * @return whether or not the given class has {@link Event} + * as a super class. + */ + public static boolean hasEventSuperClass(Class cl) { + Class superClass = cl; + while ((superClass = superClass.getSuperclass()) != null) { + if (superClass == Event.class) { + return true; + } + } + return false; + } } diff --git a/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java b/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java index 9040dd2..4101107 100644 --- a/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java +++ b/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java @@ -15,160 +15,133 @@ */ package com.clubobsidian.trident.util; -import java.io.Serializable; - import com.clubobsidian.trident.EventPriority; import com.clubobsidian.trident.MethodExecutor; -/** - * Class for implementing a doubly linked list +import java.io.Serializable; + +/** + * Class for implementing a doubly linked list * that orders the list based off of creation time and {@link EventPriority}. - * + * * @author virustotalop */ public class EventDoublyLinkedList implements Serializable { - /** - * - */ - private static final long serialVersionUID = 6359060072540225110L; - - private EventNode head; - public EventDoublyLinkedList() - { - this.head = null; - } - - /** - * @return the first node in the EventDoublyLinkedList - */ - public synchronized EventNode getHead() - { - return this.head; - } - - /** - * @param executor executor to insert - * @param priority priority of the MethodExecutor - * @return EventNode created or null if not created - */ - public synchronized EventNode insert(final MethodExecutor executor, final EventPriority priority) - { - if(executor == null || priority == null) - return null; - - int priorityValue = priority.getValue(); - EventNode newNode = new EventNode(executor, priorityValue); - if(this.head == null) - { - this.head = new EventNode(executor, priorityValue); - return newNode; - } - - EventNode found = this.findInsertionNode(priorityValue); - if(found.equals(this.head) && priorityValue < this.head.getPriority()) - { - EventNode oldHead = this.head; - this.head = newNode; - this.head.setNext(oldHead); - oldHead.setPrev(this.head); - return newNode; - } - else if(found.getPriority() > priorityValue) - { - newNode.setNext(found); - newNode.setPrev(found.getPrev()); - newNode.getPrev().setNext(newNode); - found.setPrev(newNode); - return newNode; - } - else if(found.getNext() == null) - { - found.setNext(newNode); - newNode.setPrev(found); - return newNode; - } - else - { - newNode.setNext(found.getNext()); - found.setNext(newNode); - newNode.getNext().setPrev(newNode); - return newNode; - } - } - - /** - * @param executor MethodExecutor to remove - * @return the EventNode removed or null if not found - */ - public synchronized EventNode remove(final MethodExecutor executor) - { - EventNode found = this.find(executor); - if(found == null) - return null; - - if(found.equals(this.head)) - { - if(this.head.getNext() == null) - { - this.head = null; - } - else - { - this.head = this.head.getNext(); - } - return found; - } - else if(found.getNext() == null) - { - found.getPrev().setNext(null); - return found; - } - else - { - found.getPrev().setNext(found.getNext()); - return found; - } - } - - /** - * @param executor to find - * @return found EventNode - */ - public synchronized EventNode find(final MethodExecutor executor) - { - EventNode node = this.head; - while(node != null) - { - if(node.getData().equals(executor)) - return node; - node = node.getNext(); - } - return null; - } - - /** - * @return the node to be inserted around - */ - private EventNode findInsertionNode(final int priorityValue) - { - EventNode next = this.head; - while(next != null) - { - if(next.getNext() == null) //if tail - { - return next; - } - else if(next.getPriority() == priorityValue && next.getNext().getPriority() > priorityValue) - { - return next; - } - else if(next.getPriority() > priorityValue) - { - return next; - } - next = next.getNext(); - } - return null; - } + /** + * + */ + private static final long serialVersionUID = 6359060072540225110L; + + private EventNode head; + + public EventDoublyLinkedList() { + this.head = null; + } + + /** + * @return the first node in the EventDoublyLinkedList + */ + public synchronized EventNode getHead() { + return this.head; + } + + /** + * @param executor executor to insert + * @param priority priority of the MethodExecutor + * @return EventNode created or null if not created + */ + public synchronized EventNode insert(final MethodExecutor executor, final EventPriority priority) { + if (executor == null || priority == null) + return null; + + int priorityValue = priority.getValue(); + EventNode newNode = new EventNode(executor, priorityValue); + if (this.head == null) { + this.head = new EventNode(executor, priorityValue); + return newNode; + } + + EventNode found = this.findInsertionNode(priorityValue); + if (found.equals(this.head) && priorityValue < this.head.getPriority()) { + EventNode oldHead = this.head; + this.head = newNode; + this.head.setNext(oldHead); + oldHead.setPrev(this.head); + return newNode; + } else if (found.getPriority() > priorityValue) { + newNode.setNext(found); + newNode.setPrev(found.getPrev()); + newNode.getPrev().setNext(newNode); + found.setPrev(newNode); + return newNode; + } else if (found.getNext() == null) { + found.setNext(newNode); + newNode.setPrev(found); + return newNode; + } else { + newNode.setNext(found.getNext()); + found.setNext(newNode); + newNode.getNext().setPrev(newNode); + return newNode; + } + } + + /** + * @param executor MethodExecutor to remove + * @return the EventNode removed or null if not found + */ + public synchronized EventNode remove(final MethodExecutor executor) { + EventNode found = this.find(executor); + if (found == null) + return null; + + if (found.equals(this.head)) { + if (this.head.getNext() == null) { + this.head = null; + } else { + this.head = this.head.getNext(); + } + return found; + } else if (found.getNext() == null) { + found.getPrev().setNext(null); + return found; + } else { + found.getPrev().setNext(found.getNext()); + return found; + } + } + + /** + * @param executor to find + * @return found EventNode + */ + public synchronized EventNode find(final MethodExecutor executor) { + EventNode node = this.head; + while (node != null) { + if (node.getData().equals(executor)) + return node; + node = node.getNext(); + } + return null; + } + + /** + * @return the node to be inserted around + */ + private EventNode findInsertionNode(final int priorityValue) { + EventNode next = this.head; + while (next != null) { + if (next.getNext() == null) //if tail + { + return next; + } else if (next.getPriority() == priorityValue && next.getNext().getPriority() > priorityValue) { + return next; + } else if (next.getPriority() > priorityValue) { + return next; + } + next = next.getNext(); + } + return null; + } } diff --git a/src/main/java/com/clubobsidian/trident/util/EventNode.java b/src/main/java/com/clubobsidian/trident/util/EventNode.java index 0b7fc55..6dfebee 100644 --- a/src/main/java/com/clubobsidian/trident/util/EventNode.java +++ b/src/main/java/com/clubobsidian/trident/util/EventNode.java @@ -19,66 +19,59 @@ /** * Node class for events. Used * in {@link com.clubobsidian.trident.util.EventDoublyLinkedList} - * + * * @author virustotalop */ -public class EventNode -{ - private MethodExecutor data; - private int priority; - private EventNode next; - private EventNode prev; - public EventNode(MethodExecutor data, int priority) - { - this.data = data; - this.priority = priority; - } +public class EventNode { + private MethodExecutor data; + private int priority; + private EventNode next; + private EventNode prev; - /** - * @return MethodExecutor for the node - */ - public MethodExecutor getData() - { - return this.data; - } + public EventNode(MethodExecutor data, int priority) { + this.data = data; + this.priority = priority; + } - /** - * @return integer representation of the {@link com.clubobsidian.trident.Event}'s priority - */ - public int getPriority() - { - return this.priority; - } + /** + * @return MethodExecutor for the node + */ + public MethodExecutor getData() { + return this.data; + } - /** - * @return node next to this node - */ - public synchronized EventNode getNext() - { - return this.next; - } + /** + * @return integer representation of the {@link com.clubobsidian.trident.Event}'s priority + */ + public int getPriority() { + return this.priority; + } - /** - * @param next node to be set as the next node - */ - public synchronized void setNext(final EventNode next) - { - this.next = next; - } + /** + * @return node next to this node + */ + public synchronized EventNode getNext() { + return this.next; + } - /** - * @return node behind this node - */ - public synchronized EventNode getPrev() - { - return this.prev; - } + /** + * @param next node to be set as the next node + */ + public synchronized void setNext(final EventNode next) { + this.next = next; + } - /** - * @param prev node to be set as the previous node - */ - public synchronized void setPrev(final EventNode prev) - { - this.prev = prev; - } + /** + * @return node behind this node + */ + public synchronized EventNode getPrev() { + return this.prev; + } + + /** + * @param prev node to be set as the previous node + */ + public synchronized void setPrev(final EventNode prev) { + this.prev = prev; + } } diff --git a/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java b/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java index 6681cf8..095f6db 100644 --- a/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java @@ -1,38 +1,35 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; import com.clubobsidian.trident.test.impl.TestDeadEventListener; import com.clubobsidian.trident.test.impl.TestEvent; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class DeadEventTest { - @Test - public void testNoListener() - { - EventBus eventBus = new JavassistEventBus(); - boolean listenedTo = eventBus.callEvent(new TestEvent()); - - assertFalse("Event was listened to", listenedTo); - - } - - @Test - public void testDeadListener() - { - EventBus eventBus = new JavassistEventBus(); - TestDeadEventListener deadEventListener = new TestDeadEventListener(); - eventBus.registerEvents(deadEventListener); - - eventBus.callEvent(new TestEvent()); - - System.out.println(deadEventListener.getTimesRan()); - assertTrue("Dead event triggered twice", deadEventListener.getTimesRan() == 1); - } - + @Test + public void testNoListener() { + EventBus eventBus = new JavassistEventBus(); + boolean listenedTo = eventBus.callEvent(new TestEvent()); + + assertFalse("Event was listened to", listenedTo); + + } + + @Test + public void testDeadListener() { + EventBus eventBus = new JavassistEventBus(); + TestDeadEventListener deadEventListener = new TestDeadEventListener(); + eventBus.registerEvents(deadEventListener); + + eventBus.callEvent(new TestEvent()); + + System.out.println(deadEventListener.getTimesRan()); + assertTrue("Dead event triggered twice", deadEventListener.getTimesRan() == 1); + } + } diff --git a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java index faaae2e..9b9e18b 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -1,121 +1,112 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.test.impl.TestCancelableEvent; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; import com.clubobsidian.trident.test.impl.TestOrderEvent; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public abstract class EventBusTest { - @Test - public void testEventFiring() - { - TestListener test = new TestListener("test"); - EventBus manager = this.createNewEventBus(); - boolean registered = manager.registerEvents(test); - - assertTrue("Event is not registered", registered); - assertFalse("Test is not false", test.getTest()); - - manager.callEvent(new TestEvent()); - - assertTrue("Test is not true", test.getTest()); - - manager.callEvent(new TestEvent()); - - assertFalse("Test is not false", test.getTest()); - } - - @Test - public void testEventCancellable() - { - TestListener test = new TestListener("test"); - EventBus manager = this.createNewEventBus(); - manager.registerEvents(test); - - manager.callEvent(new TestCancelableEvent()); - - assertTrue("Test is not true, event was not cancelled", test.getTest()); - } - - @Test - public void testOrder() - { - TestListener test = new TestListener(""); - EventBus manager = this.createNewEventBus(); - manager.registerEvents(test); - - manager.callEvent(new TestOrderEvent()); - - assertTrue("Events were not listened in the correct order", test.getData().equals("012345")); - } - - @Test - public void testDoubleRegister() - { - TestListener test = new TestListener("test"); - EventBus manager = this.createNewEventBus(); - manager.registerEvents(test); - - assertFalse("Event was double registered", manager.registerEvents(test)); - } - - @Test - public void testCalledEvent() - { - Event event = new TestEvent(); - EventBus manager = this.createNewEventBus(); - - assertFalse("Event call ran when event did not exist", manager.callEvent(event)); - } - - @Test - public void testUnregister() - { - TestListener test = new TestListener("test"); - EventBus manager = this.createNewEventBus(); - manager.registerEvents(test); - - assertTrue("Listener was not registered", manager.unregisterEvents(test)); - assertFalse("Listener was still registered", manager.unregisterEvents(test)); - } - - @Test - public void testEmptyCallEvent() - { - EventBus manager = this.createNewEventBus(); - boolean called = manager.callEvent(new TestEvent()); - - assertFalse("Event was called when a listener is not registered", called); - } - - @Test - public void testNullRegister() - { - EventBus manager = this.createNewEventBus(); - boolean registered = manager.registerEvents(null); - - assertFalse("Listener was still registered event though the listener was null", registered); - } - - @Test - public void testPrivateListener() - { - EventBus manager = this.createNewEventBus(); - boolean registered = manager.registerEvents(new PrivateListener()); - - assertTrue("Listener was still registered event though the listener was private", registered); - } - - protected abstract EventBus createNewEventBus(); - - - private class PrivateListener {} + @Test + public void testEventFiring() { + TestListener test = new TestListener("test"); + EventBus manager = this.createNewEventBus(); + boolean registered = manager.registerEvents(test); + + assertTrue("Event is not registered", registered); + assertFalse("Test is not false", test.getTest()); + + manager.callEvent(new TestEvent()); + + assertTrue("Test is not true", test.getTest()); + + manager.callEvent(new TestEvent()); + + assertFalse("Test is not false", test.getTest()); + } + + @Test + public void testEventCancellable() { + TestListener test = new TestListener("test"); + EventBus manager = this.createNewEventBus(); + manager.registerEvents(test); + + manager.callEvent(new TestCancelableEvent()); + + assertTrue("Test is not true, event was not cancelled", test.getTest()); + } + + @Test + public void testOrder() { + TestListener test = new TestListener(""); + EventBus manager = this.createNewEventBus(); + manager.registerEvents(test); + + manager.callEvent(new TestOrderEvent()); + + assertTrue("Events were not listened in the correct order", test.getData().equals("012345")); + } + + @Test + public void testDoubleRegister() { + TestListener test = new TestListener("test"); + EventBus manager = this.createNewEventBus(); + manager.registerEvents(test); + + assertFalse("Event was double registered", manager.registerEvents(test)); + } + + @Test + public void testCalledEvent() { + Event event = new TestEvent(); + EventBus manager = this.createNewEventBus(); + + assertFalse("Event call ran when event did not exist", manager.callEvent(event)); + } + + @Test + public void testUnregister() { + TestListener test = new TestListener("test"); + EventBus manager = this.createNewEventBus(); + manager.registerEvents(test); + + assertTrue("Listener was not registered", manager.unregisterEvents(test)); + assertFalse("Listener was still registered", manager.unregisterEvents(test)); + } + + @Test + public void testEmptyCallEvent() { + EventBus manager = this.createNewEventBus(); + boolean called = manager.callEvent(new TestEvent()); + + assertFalse("Event was called when a listener is not registered", called); + } + + @Test + public void testNullRegister() { + EventBus manager = this.createNewEventBus(); + boolean registered = manager.registerEvents(null); + + assertFalse("Listener was still registered event though the listener was null", registered); + } + + @Test + public void testPrivateListener() { + EventBus manager = this.createNewEventBus(); + boolean registered = manager.registerEvents(new PrivateListener()); + + assertTrue("Listener was still registered event though the listener was private", registered); + } + + protected abstract EventBus createNewEventBus(); + + + private class PrivateListener { + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java index a10aa5e..c312d61 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java @@ -15,14 +15,6 @@ */ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Random; - -import org.junit.Test; - import com.clubobsidian.trident.EventPriority; import com.clubobsidian.trident.MethodExecutor; import com.clubobsidian.trident.test.impl.TestEvent; @@ -30,303 +22,270 @@ import com.clubobsidian.trident.test.impl.TestMethodExecutor; import com.clubobsidian.trident.util.EventDoublyLinkedList; import com.clubobsidian.trident.util.EventNode; +import org.junit.Test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Random; + +import static org.junit.Assert.assertTrue; public class EventDoublyLinkedListTest { - @Test - public void testOrder() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - - TestListener test = new TestListener("test"); - MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode low = list.insert(executor, EventPriority.LOW); - assertTrue("Low could not be inserted at head", low != null); - - assertTrue("Low is not head", list.getHead().getData().equals(executor)); - - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode lowest = list.insert(executor2, EventPriority.LOWEST); - assertTrue("Lowest could not be inserted", lowest != null); - - assertTrue("Lowest is not head", list.getHead().getData().equals(executor2)); - - - TestListener test3 = new TestListener("test3"); - MethodExecutor executor3 = new TestMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode nextLowest = list.insert(executor3, EventPriority.LOWEST); - assertTrue("NextLowest could not be inserted", nextLowest != null); - - assertTrue("NextLowest is not next to head", list.getHead().getNext().getData().equals(executor3)); - - - TestListener test4 = new TestListener("test4"); - MethodExecutor executor4 = new TestMethodExecutor(test4, test4.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode monitor = list.insert(executor4, EventPriority.MONITOR); - assertTrue("Monitor could not be inserted", monitor != null); - - assertTrue("Monitor is not tail", list.find(executor4).getData().equals(executor4)); - - - TestListener test5 = new TestListener("test5"); - MethodExecutor executor5 = new TestMethodExecutor(test5, test5.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode high = list.insert(executor5, EventPriority.HIGH); - assertTrue("High could not be inserted", high != null); - - assertTrue("High next node is not priority monitor", list.find(executor5).getNext().getData().equals(executor4)); - - TestListener test6 = new TestListener("test6"); - MethodExecutor executor6 = new TestMethodExecutor(test6, test6.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode normal = list.insert(executor6, EventPriority.NORMAL); - assertTrue("Normal could not be inserted", normal != null); - - assertTrue("Normal next node is not priority high", list.find(executor6).getNext().getData().equals(executor5)); - - - TestListener test7 = new TestListener("test7"); - MethodExecutor executor7 = new TestMethodExecutor(test7, test7.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode highest = list.insert(executor7, EventPriority.HIGHEST); - assertTrue("Highest could not be inserted", highest != null); - - assertTrue("Highest next node is not priority monitor", list.find(executor7).getNext().getData().equals(executor4)); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void testRemoval() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test = new TestListener("test1"); - MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); - list.insert(executor, EventPriority.MONITOR); - - assertTrue("Monitor is not head", list.getHead().getData().equals(executor)); - list.remove(executor); - assertTrue("Head is not null after monitor removal", list.getHead() == null); - - for(int i = EventPriority.values()[0].getValue(); i < (EventPriority.values()[EventPriority.values().length - 1]).getValue() + 1; i++) - { - list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class) , false), EventPriority.getByValue(i)); - } - - EventNode node = list.getHead(); - int removalCount = 0; - while(node != null) - { - list.remove(node.getData()); - removalCount += 1; - node = node.getNext(); - } - - assertTrue("Head is not null after traversing after removing all node", list.getHead() == null); - assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); - - for(int i = (EventPriority.values()[EventPriority.values().length - 1]).getValue(); i > -1 ; i--) - { - list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(i)); - } - - node = list.getHead(); - removalCount = 0; - while(node != null) - { - list.remove(node.getData()); - removalCount += 1; - node = node.getNext(); - } - - assertTrue("Head is not null after traversing after removing all nodes reverse", list.getHead() == null); - assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); - - Random rand = new Random(); - - int iterate = 10000; - for(int i = 0; i < iterate; i++) - { - - rand.setSeed(System.nanoTime()); - int next = rand.nextInt(6); - EventNode inserted = list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(next)); - - assertTrue("Insert failed for random insert for removal", inserted != null); - } - - node = list.getHead(); - removalCount = 0; - while(node != null) - { - list.remove(node.getData()); - removalCount += 1; - node = node.getNext(); - } - - assertTrue("Head is not null after traversing after removing all nodes after random insert", list.getHead() == null); - assertTrue("Removed nodes are not equal to iterating length after random insert", iterate == removalCount); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void emptyLinkedListTest() - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test = new TestListener("test1"); - try - { - MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); - assertTrue("Executor was removed", list.remove(executor) == null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void nextIsNullAndNotHeadRemove() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor1, EventPriority.LOWEST); - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor2, EventPriority.LOW); - - EventNode removed = list.remove(executor2); - - assertTrue("EventNode data was not equal", removed.getData().equals(executor2)); - - assertTrue("EventNode previous node's next node was not null", removed.getPrev().getNext() == null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void foundIsMiddleNodeRemoveTest() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor1, EventPriority.LOWEST); - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor2, EventPriority.LOW); - - TestListener test3 = new TestListener("test3"); - MethodExecutor executor3 = new TestMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor3, EventPriority.NORMAL); - - EventNode removed = list.remove(executor2); - - assertTrue("Previous node's next node was not set to removed next node", removed.getPrev().getNext().equals(removed.getNext())); - - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void findMethodExecutorThatDoesNotExistTest() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - assertTrue("Executor was found while not inserted", list.find(executor1) == null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test //This should never happen under normal circumstances but is being used for code coverage - public void findInsertNull() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - - Method findInsertion = list.getClass().getDeclaredMethod("findInsertionNode", int.class); - findInsertion.setAccessible(true); - assertTrue("Null node was not found", findInsertion.invoke(list, 6) == null); - } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - e.printStackTrace(); - } - } - - @Test - public void findIfFoundNodePriorityIsTheSameTest() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor1, EventPriority.LOWEST); - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - - - EventPriority priority = EventPriority.LOWEST; - EventNode inserted = list.insert(executor2, priority); - - assertTrue("Previous node's priority is not the same", inserted.getPriority() == priority.getValue()); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void methodExecutorNullTest() - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - EventNode inserted = list.insert(null, null); - assertTrue("Inserted event node was not null for a null method executor", inserted == null); - } - - @Test - public void eventPriorityNullTest() - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - EventNode inserted = list.insert(new TestMethodExecutor(null, null, false), null); - assertTrue("Inserted event node was not null for a null event priority", inserted == null); - } + @Test + public void testOrder() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + + TestListener test = new TestListener("test"); + MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode low = list.insert(executor, EventPriority.LOW); + assertTrue("Low could not be inserted at head", low != null); + + assertTrue("Low is not head", list.getHead().getData().equals(executor)); + + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode lowest = list.insert(executor2, EventPriority.LOWEST); + assertTrue("Lowest could not be inserted", lowest != null); + + assertTrue("Lowest is not head", list.getHead().getData().equals(executor2)); + + + TestListener test3 = new TestListener("test3"); + MethodExecutor executor3 = new TestMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode nextLowest = list.insert(executor3, EventPriority.LOWEST); + assertTrue("NextLowest could not be inserted", nextLowest != null); + + assertTrue("NextLowest is not next to head", list.getHead().getNext().getData().equals(executor3)); + + + TestListener test4 = new TestListener("test4"); + MethodExecutor executor4 = new TestMethodExecutor(test4, test4.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode monitor = list.insert(executor4, EventPriority.MONITOR); + assertTrue("Monitor could not be inserted", monitor != null); + + assertTrue("Monitor is not tail", list.find(executor4).getData().equals(executor4)); + + + TestListener test5 = new TestListener("test5"); + MethodExecutor executor5 = new TestMethodExecutor(test5, test5.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode high = list.insert(executor5, EventPriority.HIGH); + assertTrue("High could not be inserted", high != null); + + assertTrue("High next node is not priority monitor", list.find(executor5).getNext().getData().equals(executor4)); + + TestListener test6 = new TestListener("test6"); + MethodExecutor executor6 = new TestMethodExecutor(test6, test6.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode normal = list.insert(executor6, EventPriority.NORMAL); + assertTrue("Normal could not be inserted", normal != null); + + assertTrue("Normal next node is not priority high", list.find(executor6).getNext().getData().equals(executor5)); + + + TestListener test7 = new TestListener("test7"); + MethodExecutor executor7 = new TestMethodExecutor(test7, test7.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode highest = list.insert(executor7, EventPriority.HIGHEST); + assertTrue("Highest could not be inserted", highest != null); + + assertTrue("Highest next node is not priority monitor", list.find(executor7).getNext().getData().equals(executor4)); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void testRemoval() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test = new TestListener("test1"); + MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); + list.insert(executor, EventPriority.MONITOR); + + assertTrue("Monitor is not head", list.getHead().getData().equals(executor)); + list.remove(executor); + assertTrue("Head is not null after monitor removal", list.getHead() == null); + + for (int i = EventPriority.values()[0].getValue(); i < (EventPriority.values()[EventPriority.values().length - 1]).getValue() + 1; i++) { + list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(i)); + } + + EventNode node = list.getHead(); + int removalCount = 0; + while (node != null) { + list.remove(node.getData()); + removalCount += 1; + node = node.getNext(); + } + + assertTrue("Head is not null after traversing after removing all node", list.getHead() == null); + assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); + + for (int i = (EventPriority.values()[EventPriority.values().length - 1]).getValue(); i > -1; i--) { + list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(i)); + } + + node = list.getHead(); + removalCount = 0; + while (node != null) { + list.remove(node.getData()); + removalCount += 1; + node = node.getNext(); + } + + assertTrue("Head is not null after traversing after removing all nodes reverse", list.getHead() == null); + assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); + + Random rand = new Random(); + + int iterate = 10000; + for (int i = 0; i < iterate; i++) { + + rand.setSeed(System.nanoTime()); + int next = rand.nextInt(6); + EventNode inserted = list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(next)); + + assertTrue("Insert failed for random insert for removal", inserted != null); + } + + node = list.getHead(); + removalCount = 0; + while (node != null) { + list.remove(node.getData()); + removalCount += 1; + node = node.getNext(); + } + + assertTrue("Head is not null after traversing after removing all nodes after random insert", list.getHead() == null); + assertTrue("Removed nodes are not equal to iterating length after random insert", iterate == removalCount); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void emptyLinkedListTest() { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test = new TestListener("test1"); + try { + MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); + assertTrue("Executor was removed", list.remove(executor) == null); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void nextIsNullAndNotHeadRemove() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor1, EventPriority.LOWEST); + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor2, EventPriority.LOW); + + EventNode removed = list.remove(executor2); + + assertTrue("EventNode data was not equal", removed.getData().equals(executor2)); + + assertTrue("EventNode previous node's next node was not null", removed.getPrev().getNext() == null); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void foundIsMiddleNodeRemoveTest() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor1, EventPriority.LOWEST); + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor2, EventPriority.LOW); + + TestListener test3 = new TestListener("test3"); + MethodExecutor executor3 = new TestMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor3, EventPriority.NORMAL); + + EventNode removed = list.remove(executor2); + + assertTrue("Previous node's next node was not set to removed next node", removed.getPrev().getNext().equals(removed.getNext())); + + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void findMethodExecutorThatDoesNotExistTest() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + assertTrue("Executor was found while not inserted", list.find(executor1) == null); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test //This should never happen under normal circumstances but is being used for code coverage + public void findInsertNull() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + + Method findInsertion = list.getClass().getDeclaredMethod("findInsertionNode", int.class); + findInsertion.setAccessible(true); + assertTrue("Null node was not found", findInsertion.invoke(list, 6) == null); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void findIfFoundNodePriorityIsTheSameTest() { + try { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor1, EventPriority.LOWEST); + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + + + EventPriority priority = EventPriority.LOWEST; + EventNode inserted = list.insert(executor2, priority); + + assertTrue("Previous node's priority is not the same", inserted.getPriority() == priority.getValue()); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void methodExecutorNullTest() { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + EventNode inserted = list.insert(null, null); + assertTrue("Inserted event node was not null for a null method executor", inserted == null); + } + + @Test + public void eventPriorityNullTest() { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + EventNode inserted = list.insert(new TestMethodExecutor(null, null, false), null); + assertTrue("Inserted event node was not null for a null event priority", inserted == null); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java b/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java index 04bf09b..ea6e107 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java @@ -1,24 +1,21 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; - +import com.clubobsidian.trident.EventPriority; import org.junit.Test; -import com.clubobsidian.trident.EventPriority; +import static org.junit.Assert.assertTrue; public class EventPriorityTest { - @Test - public void testOutOfLowerBounds() - { - EventPriority priority = EventPriority.getByValue(-1); - assertTrue("Priority was not null when going below bounds", priority == null); - } - - @Test - public void testOutOfUpperBounds() - { - EventPriority priority = EventPriority.getByValue(EventPriority.values().length); - assertTrue("Priority was not null when going above bounds", priority == null); - } + @Test + public void testOutOfLowerBounds() { + EventPriority priority = EventPriority.getByValue(-1); + assertTrue("Priority was not null when going below bounds", priority == null); + } + + @Test + public void testOutOfUpperBounds() { + EventPriority priority = EventPriority.getByValue(EventPriority.values().length); + assertTrue("Priority was not null when going above bounds", priority == null); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/EventTest.java b/src/test/java/com/clubobsidian/trident/test/EventTest.java index 81873a1..455e855 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventTest.java @@ -1,18 +1,16 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - import com.clubobsidian.trident.Event; import com.clubobsidian.trident.test.impl.TestEvent; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; public class EventTest { - @Test - public void testName() - { - Event event = new TestEvent(); - assertTrue("Event name is not \"TestEvent\"", event.getName().equals("TestEvent")); - } + @Test + public void testName() { + Event event = new TestEvent(); + assertTrue("Event name is not \"TestEvent\"", event.getName().equals("TestEvent")); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java index e96b68d..7cd57ad 100644 --- a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java +++ b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java @@ -16,26 +16,24 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; import com.clubobsidian.trident.test.impl.TestCancelableEvent; import com.clubobsidian.trident.test.impl.TestListenerIgnore; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; public class IgnoreCanceledTest { - @Test - public void ignoredCanceled() - { - TestListenerIgnore listener = new TestListenerIgnore(); - EventBus manager = new JavassistEventBus(); - manager.registerEvents(listener); - manager.callEvent(new TestCancelableEvent()); - - assertTrue("Event was not canceled", listener.isCanceled()); - assertTrue("Event was not ignored", listener.getIgnored()); - } + @Test + public void ignoredCanceled() { + TestListenerIgnore listener = new TestListenerIgnore(); + EventBus manager = new JavassistEventBus(); + manager.registerEvents(listener); + manager.callEvent(new TestCancelableEvent()); + + assertTrue("Event was not canceled", listener.isCanceled()); + assertTrue("Event was not ignored", listener.getIgnored()); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index 84bce65..c9084bb 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -15,8 +15,12 @@ */ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; +import com.clubobsidian.trident.test.impl.TestListener; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -25,69 +29,54 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; -import com.clubobsidian.trident.test.impl.TestListener; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class JavaAssistEventBusTest extends EventBusTest { - - @Test - public void testClassPoolExists() - { - JavassistEventBus eventBus = new JavassistEventBus(); - assertTrue("No class pool for JavaAssist event bus", eventBus.getClassPool() != null); - } - - @Test - public void testNullMethodOnMethodExecutor() - { - JavassistEventBus eventBus = new JavassistEventBus(); - try - { - Method generate = eventBus.getClass().getDeclaredMethod("generateMethodExecutor", Object.class, Method.class, boolean.class); - generate.setAccessible(true); - Object methodExecutor = generate.invoke(eventBus, null, null, false); - assertTrue("Method executor is not null even though a null listener was passed", methodExecutor == null); - } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - e.printStackTrace(); - } - } - - @Test - public void testFrozenMethodExecutor() - { - try - { - JavassistEventBus eventBus = new JavassistEventBus(); - eventBus.registerEvents(new TestListener("data")); - Field mapField = JavassistEventBus.class.getDeclaredField("map"); - mapField.setAccessible(true); - ConcurrentMap savedMap = (ConcurrentMap) mapField.get(null); - mapField.set(null, new ConcurrentHashMap()); - boolean registered = eventBus.registerEvents(new TestListener("data")); + @Test + public void testClassPoolExists() { + JavassistEventBus eventBus = new JavassistEventBus(); + assertTrue("No class pool for JavaAssist event bus", eventBus.getClassPool() != null); + } + + @Test + public void testNullMethodOnMethodExecutor() { + JavassistEventBus eventBus = new JavassistEventBus(); + try { + Method generate = eventBus.getClass().getDeclaredMethod("generateMethodExecutor", Object.class, Method.class, boolean.class); + generate.setAccessible(true); + Object methodExecutor = generate.invoke(eventBus, null, null, false); + assertTrue("Method executor is not null even though a null listener was passed", methodExecutor == null); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + @Test + public void testFrozenMethodExecutor() { + try { + JavassistEventBus eventBus = new JavassistEventBus(); + eventBus.registerEvents(new TestListener("data")); + Field mapField = JavassistEventBus.class.getDeclaredField("map"); + mapField.setAccessible(true); + ConcurrentMap savedMap = (ConcurrentMap) mapField.get(null); + + mapField.set(null, new ConcurrentHashMap()); + boolean registered = eventBus.registerEvents(new TestListener("data")); + + mapField.set(null, savedMap); + System.out.println("Set map back to prior state"); - mapField.set(null, savedMap); - System.out.println("Set map back to prior state"); + assertFalse("Was able to register event with invalid map", registered); + } catch (IllegalArgumentException | SecurityException | IllegalAccessException | NoSuchFieldException e) { + e.printStackTrace(); + } + } - assertFalse("Was able to register event with invalid map", registered); - } - catch (IllegalArgumentException | SecurityException | IllegalAccessException | NoSuchFieldException e) - { - e.printStackTrace(); - } - } - - @Override - protected EventBus createNewEventBus() - { - return new JavassistEventBus(); - } + @Override + protected EventBus createNewEventBus() { + return new JavassistEventBus(); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java b/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java index 04023bb..5e9d19f 100644 --- a/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java +++ b/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java @@ -1,11 +1,5 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.Test; - import com.clubobsidian.trident.EventPriority; import com.clubobsidian.trident.MethodExecutor; import com.clubobsidian.trident.test.impl.TestEvent; @@ -13,52 +7,49 @@ import com.clubobsidian.trident.test.impl.TestMethodExecutor; import com.clubobsidian.trident.util.EventDoublyLinkedList; import com.clubobsidian.trident.util.EventNode; +import org.junit.Test; + +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.Assert.assertTrue; public class MultiThreadingTest { - - @Test - public void multiThreadingTestEventDoublyLinkedList() - { - AtomicInteger count = new AtomicInteger(0); - final EventDoublyLinkedList list = new EventDoublyLinkedList(); - Runnable testRunnable = new Runnable() - { - @Override - public void run() - { - for(int i = 0; i < 1000; i++) - { - try - { - int inc = count.incrementAndGet(); - TestListener testListener = new TestListener("test" + inc); - MethodExecutor testExecutor = new TestMethodExecutor(testListener, testListener.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode node = list.insert(testExecutor, EventPriority.LOWEST); - assertTrue("Node was null when inserted", node != null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - Thread.currentThread().interrupt(); - } - }; - Thread th1 = new Thread(testRunnable); - Thread th2 = new Thread(testRunnable); - - th1.start(); - th2.start(); - - while(th1.isAlive() || th2.isAlive()); - - int nodeCount = 0; - EventNode node = list.getHead(); - while(node != null) - { - nodeCount+= 1; - node = node.getNext(); - } - assertTrue("Node count not equal when running from multiple thread", nodeCount == count.get()); - } + + @Test + public void multiThreadingTestEventDoublyLinkedList() { + AtomicInteger count = new AtomicInteger(0); + final EventDoublyLinkedList list = new EventDoublyLinkedList(); + Runnable testRunnable = new Runnable() { + @Override + public void run() { + for (int i = 0; i < 1000; i++) { + try { + int inc = count.incrementAndGet(); + TestListener testListener = new TestListener("test" + inc); + MethodExecutor testExecutor = new TestMethodExecutor(testListener, testListener.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode node = list.insert(testExecutor, EventPriority.LOWEST); + assertTrue("Node was null when inserted", node != null); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + Thread.currentThread().interrupt(); + } + }; + Thread th1 = new Thread(testRunnable); + Thread th2 = new Thread(testRunnable); + + th1.start(); + th2.start(); + + while (th1.isAlive() || th2.isAlive()) ; + + int nodeCount = 0; + EventNode node = list.getHead(); + while (node != null) { + nodeCount += 1; + node = node.getNext(); + } + assertTrue("Node count not equal when running from multiple thread", nodeCount == count.get()); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java index 5d61a83..2d3f860 100644 --- a/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java @@ -1,20 +1,18 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertFalse; - -import org.junit.Test; - import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.test.impl.TestEventBus; import com.clubobsidian.trident.test.impl.TestListener; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; public class OtherEventBusTest { - @Test - public void testNullExecutor() - { - EventBus bus = new TestEventBus(); - boolean registered = bus.registerEvents(new TestListener("data")); - assertFalse("Listener was registered even though MethodExecutor is null", registered); - } + @Test + public void testNullExecutor() { + EventBus bus = new TestEventBus(); + boolean registered = bus.registerEvents(new TestListener("data")); + assertFalse("Listener was registered even though MethodExecutor is null", registered); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java index 58b317c..1a38106 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java @@ -20,9 +20,8 @@ public class ReflectionEventBusTest extends EventBusTest { - @Override - protected EventBus createNewEventBus() - { - return new ReflectionEventBus(); - } + @Override + protected EventBus createNewEventBus() { + return new ReflectionEventBus(); + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index 1a00954..3d4cf4a 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -16,54 +16,45 @@ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.Method; - -import org.junit.Test; - import com.clubobsidian.trident.MethodExecutor; import com.clubobsidian.trident.eventbus.reflection.ReflectionMethodExecutor; -import com.clubobsidian.trident.test.impl.TestWrongArgumentListener; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; import com.clubobsidian.trident.test.impl.TestWrongArgumentEvent; +import com.clubobsidian.trident.test.impl.TestWrongArgumentListener; +import org.junit.Test; + +import java.lang.reflect.Method; + +import static org.junit.Assert.assertTrue; public class ReflectionMiscEventTest { - @Test - public void methodExecutorTest() - { - try - { - TestListener listener = new TestListener("test"); - Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); - MethodExecutor executor = new ReflectionMethodExecutor(listener, testEventMethod, false); - - assertTrue("Listeners are not equal for method executor", listener.equals(executor.getListener())); - assertTrue("Methods are not equal for method executor", testEventMethod.equals(executor.getMethod())); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void methodExecutorPrivateTest() - { - try - { - TestWrongArgumentListener listener = new TestWrongArgumentListener("test"); - Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); - MethodExecutor executor = new ReflectionMethodExecutor(listener, testEventMethod, false); - executor.execute(new TestWrongArgumentEvent()); - - assertTrue("Executor was able to execute method on a listener with a different event class", listener.getTest() == false); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } + @Test + public void methodExecutorTest() { + try { + TestListener listener = new TestListener("test"); + Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); + MethodExecutor executor = new ReflectionMethodExecutor(listener, testEventMethod, false); + + assertTrue("Listeners are not equal for method executor", listener.equals(executor.getListener())); + assertTrue("Methods are not equal for method executor", testEventMethod.equals(executor.getMethod())); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Test + public void methodExecutorPrivateTest() { + try { + TestWrongArgumentListener listener = new TestWrongArgumentListener("test"); + Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); + MethodExecutor executor = new ReflectionMethodExecutor(listener, testEventMethod, false); + executor.execute(new TestWrongArgumentEvent()); + + assertTrue("Executor was able to execute method on a listener with a different event class", listener.getTest() == false); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } } diff --git a/src/test/java/com/clubobsidian/trident/test/UtilTest.java b/src/test/java/com/clubobsidian/trident/test/UtilTest.java index 1dd87a2..bd46b16 100644 --- a/src/test/java/com/clubobsidian/trident/test/UtilTest.java +++ b/src/test/java/com/clubobsidian/trident/test/UtilTest.java @@ -15,25 +15,23 @@ */ package com.clubobsidian.trident.test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - -import org.junit.Test; - import com.clubobsidian.trident.Event; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.util.ClassUtil; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class UtilTest { - @Test - public void classUtilTest() - { - Event event = new TestEvent(); - boolean superClass = ClassUtil.hasEventSuperClass(event.getClass()); - assertTrue("Super class for TestEvent was not event", superClass); - - superClass = ClassUtil.hasEventSuperClass(String.class); - assertFalse("Super class is not null for string class", superClass); - } + @Test + public void classUtilTest() { + Event event = new TestEvent(); + boolean superClass = ClassUtil.hasEventSuperClass(event.getClass()); + assertTrue("Super class for TestEvent was not event", superClass); + + superClass = ClassUtil.hasEventSuperClass(String.class); + assertFalse("Super class is not null for string class", superClass); + } } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java index 8725695..74066ba 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java @@ -19,16 +19,14 @@ public class TestCancelableEvent extends TestEvent implements Cancelable { - private boolean canceled; - - @Override - public boolean isCanceled() - { - return this.canceled; - } - - public void setCanceled(boolean cancelled) - { - this.canceled = cancelled; - } + private boolean canceled; + + @Override + public boolean isCanceled() { + return this.canceled; + } + + public void setCanceled(boolean cancelled) { + this.canceled = cancelled; + } } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java index 76e551f..65f4147 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java @@ -5,22 +5,20 @@ public class TestDeadEventListener { - private int timesRan; - public TestDeadEventListener() - { - this.timesRan = 0; - } - - - @EventHandler - public void onDeadEvent(DeadEvent event) - { - System.out.println("Dead event: " + event.getDeadEvent().getName()); - this.timesRan += 1; - } - - public int getTimesRan() - { - return this.timesRan; - } + private int timesRan; + + public TestDeadEventListener() { + this.timesRan = 0; + } + + + @EventHandler + public void onDeadEvent(DeadEvent event) { + System.out.println("Dead event: " + event.getDeadEvent().getName()); + this.timesRan += 1; + } + + public int getTimesRan() { + return this.timesRan; + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java index abda403..3ace3da 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java @@ -16,10 +16,9 @@ package com.clubobsidian.trident.test.impl; /** - * * Extends TestEventSuper, is used partially in testing of getting * the super class for the event class. - * */ -public class TestEvent extends TestEventSuper {} +public class TestEvent extends TestEventSuper { +} diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java index 667bc1c..054e8a4 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java @@ -1,15 +1,14 @@ package com.clubobsidian.trident.test.impl; -import java.lang.reflect.Method; - import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.MethodExecutor; +import java.lang.reflect.Method; + public class TestEventBus extends EventBus { - @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) - { - return null; - } + @Override + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + return null; + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java index 7f1e7b3..d7165fd 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java @@ -18,10 +18,9 @@ import com.clubobsidian.trident.Event; /** - * * Used in testing for unit tests. * Should not be called, extended by {@link} TestEvent - * */ -public class TestEventSuper extends Event {} +public class TestEventSuper extends Event { +} diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java index b8c97d9..9f3218f 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java @@ -19,79 +19,67 @@ import com.clubobsidian.trident.EventPriority; public class TestListener { - - private String data; - private boolean test; - public TestListener(String data) - { - this.data = data; - this.test = false; - } - - public String getData() - { - return this.data; - } - - public boolean getTest() - { - return this.test; - } - - @EventHandler - public void test(TestEvent event) - { - this.test = !test; - } - - @EventHandler - public void testCanceleable(TestCancelableEvent event) - { - event.setCanceled(true); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void testCancelableHighest(TestCancelableEvent event) - { - if(event.isCanceled()) - { - this.test = true; - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void testOrderLowest(TestOrderEvent event) - { - this.data += "0"; - } - - @EventHandler(priority = EventPriority.LOW) - public void testOrderLow(TestOrderEvent event) - { - this.data += "1"; - } - - @EventHandler - public void testOrderNormal(TestOrderEvent event) - { - this.data += 2; - } - - @EventHandler(priority = EventPriority.HIGH) - public void testOrderHigh(TestOrderEvent event) - { - this.data += "3"; - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void testOrderHighest(TestOrderEvent event) - { - this.data += "4"; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void testOrderMonitor(TestOrderEvent event) - { - this.data += "5"; - } + + private String data; + private boolean test; + + public TestListener(String data) { + this.data = data; + this.test = false; + } + + public String getData() { + return this.data; + } + + public boolean getTest() { + return this.test; + } + + @EventHandler + public void test(TestEvent event) { + this.test = !test; + } + + @EventHandler + public void testCanceleable(TestCancelableEvent event) { + event.setCanceled(true); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void testCancelableHighest(TestCancelableEvent event) { + if (event.isCanceled()) { + this.test = true; + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void testOrderLowest(TestOrderEvent event) { + this.data += "0"; + } + + @EventHandler(priority = EventPriority.LOW) + public void testOrderLow(TestOrderEvent event) { + this.data += "1"; + } + + @EventHandler + public void testOrderNormal(TestOrderEvent event) { + this.data += 2; + } + + @EventHandler(priority = EventPriority.HIGH) + public void testOrderHigh(TestOrderEvent event) { + this.data += "3"; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void testOrderHighest(TestOrderEvent event) { + this.data += "4"; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void testOrderMonitor(TestOrderEvent event) { + this.data += "5"; + } } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java index c25d364..bf26d6c 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java @@ -20,29 +20,25 @@ public class TestListenerIgnore { - private boolean canceled = false; - private boolean ignored = true; - - public boolean isCanceled() - { - return this.canceled; - } - - public boolean getIgnored() - { - return this.ignored; - } - - @EventHandler - public void setCanceled(TestCancelableEvent e) - { - e.setCanceled(true); - this.canceled = true; - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCanceled = true) - public void test(TestCancelableEvent e) - { - this.ignored = false; - } + private boolean canceled = false; + private boolean ignored = true; + + public boolean isCanceled() { + return this.canceled; + } + + public boolean getIgnored() { + return this.ignored; + } + + @EventHandler + public void setCanceled(TestCancelableEvent e) { + e.setCanceled(true); + this.canceled = true; + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCanceled = true) + public void test(TestCancelableEvent e) { + this.ignored = false; + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java index aa3e298..e4de204 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java @@ -1,20 +1,18 @@ package com.clubobsidian.trident.test.impl; -import java.lang.reflect.Method; - import com.clubobsidian.trident.Event; import com.clubobsidian.trident.MethodExecutor; +import java.lang.reflect.Method; + public class TestMethodExecutor extends MethodExecutor { - public TestMethodExecutor(Object listener, Method method, boolean ignoreCanceled) - { - super(listener, method, ignoreCanceled); - } + public TestMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + super(listener, method, ignoreCanceled); + } + + @Override + public void execute(Event event) { - @Override - public void execute(Event event) - { - - } + } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java index d66f26a..acf0975 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java @@ -17,4 +17,5 @@ import com.clubobsidian.trident.Event; -public class TestOrderEvent extends Event {} +public class TestOrderEvent extends Event { +} diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java index f670036..9eab9f4 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java @@ -16,27 +16,24 @@ package com.clubobsidian.trident.test.impl; public class TestWrongArgumentListener { - - private String data; - private boolean test; - public TestWrongArgumentListener(String data) - { - this.data = data; - this.test = false; - } - - public String getData() - { - return this.data; - } - - public boolean getTest() - { - return this.test; - } - - public void test(TestEvent event) - { - this.test = !test; - } + + private String data; + private boolean test; + + public TestWrongArgumentListener(String data) { + this.data = data; + this.test = false; + } + + public String getData() { + return this.data; + } + + public boolean getTest() { + return this.test; + } + + public void test(TestEvent event) { + this.test = !test; + } } \ No newline at end of file From ce4b37c7089a39d10f484aa37fbf0da387f6dad9 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Fri, 2 Apr 2021 07:44:58 -0700 Subject: [PATCH 2/5] Implement method handle event bus --- .../methodhandle/MethodHandleEventBus.java | 22 +++++++++++++ .../methodhandle/MethodHandleExecutor.java | 31 +++++++++++++++++++ .../test/MethodHandleEventBusTest.java | 28 +++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java create mode 100644 src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java create mode 100644 src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java diff --git a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java new file mode 100644 index 0000000..c5d5d82 --- /dev/null +++ b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java @@ -0,0 +1,22 @@ +package com.clubobsidian.trident.eventbus.methodhandle; + +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.MethodExecutor; + +import java.lang.reflect.Method; + +/** + * {@inheritDoc} + */ +public class MethodHandleEventBus extends EventBus { + + @Override + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + try { + return new MethodHandleExecutor(listener, method, ignoreCanceled); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java new file mode 100644 index 0000000..a3690d3 --- /dev/null +++ b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java @@ -0,0 +1,31 @@ +package com.clubobsidian.trident.eventbus.methodhandle; + +import com.clubobsidian.trident.Event; +import com.clubobsidian.trident.MethodExecutor; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * {@inheritDoc} + */ +public class MethodHandleExecutor extends MethodExecutor { + + private MethodHandle handle; + + public MethodHandleExecutor(Object listener, Method method, boolean ignoreCanceled) throws IllegalAccessException { + super(listener, method, ignoreCanceled); + this.handle = MethodHandles.lookup().unreflect(method); + } + + @Override + public void execute(final Event event) { + try { + this.handle.invoke(this.getListener(), event); + } catch (Throwable ex) { + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java new file mode 100644 index 0000000..5d3c1e1 --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java @@ -0,0 +1,28 @@ +/* + Copyright 2019 Club Obsidian and contributors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.clubobsidian.trident.test; + +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.eventbus.methodhandle.MethodHandleEventBus; +import com.clubobsidian.trident.eventbus.reflection.ReflectionEventBus; + +public class MethodHandleEventBusTest extends EventBusTest { + + @Override + protected EventBus createNewEventBus() { + return new MethodHandleEventBus(); + } +} \ No newline at end of file From cc733abe5c0c340cbce63c38fa3632f1af8fe89a Mon Sep 17 00:00:00 2001 From: virustotalop Date: Fri, 2 Apr 2021 07:59:41 -0700 Subject: [PATCH 3/5] Move cancel spelling to British spelling of the word --- .../{Cancelable.java => Cancellable.java} | 6 ++-- .../com/clubobsidian/trident/EventBus.java | 28 +++++++++---------- .../clubobsidian/trident/EventHandler.java | 2 +- .../clubobsidian/trident/EventPriority.java | 4 +-- .../clubobsidian/trident/MethodExecutor.java | 16 +++++------ .../clubobsidian/trident/event/DeadEvent.java | 2 +- .../eventbus/javassist/JavassistEventBus.java | 12 ++++---- .../methodhandle/MethodHandleEventBus.java | 4 +-- .../methodhandle/MethodHandleExecutor.java | 7 ++--- .../reflection/ReflectionEventBus.java | 4 +-- .../reflection/ReflectionMethodExecutor.java | 4 +-- .../trident/test/EventBusTest.java | 4 +-- ...eledTest.java => IgnoreCancelledTest.java} | 10 +++---- ...leEvent.java => TestCancellableEvent.java} | 14 +++++----- .../trident/test/impl/TestEventBus.java | 2 +- .../trident/test/impl/TestListener.java | 8 +++--- .../trident/test/impl/TestListenerIgnore.java | 16 +++++------ .../trident/test/impl/TestMethodExecutor.java | 4 +-- 18 files changed, 72 insertions(+), 75 deletions(-) rename src/main/java/com/clubobsidian/trident/{Cancelable.java => Cancellable.java} (90%) rename src/test/java/com/clubobsidian/trident/test/{IgnoreCanceledTest.java => IgnoreCancelledTest.java} (81%) rename src/test/java/com/clubobsidian/trident/test/impl/{TestCancelableEvent.java => TestCancellableEvent.java} (69%) diff --git a/src/main/java/com/clubobsidian/trident/Cancelable.java b/src/main/java/com/clubobsidian/trident/Cancellable.java similarity index 90% rename from src/main/java/com/clubobsidian/trident/Cancelable.java rename to src/main/java/com/clubobsidian/trident/Cancellable.java index 684c962..4435bf5 100644 --- a/src/main/java/com/clubobsidian/trident/Cancelable.java +++ b/src/main/java/com/clubobsidian/trident/Cancellable.java @@ -22,17 +22,17 @@ * * @author virustotalop */ -public interface Cancelable { +public interface Cancellable { /** * Returns if the event is cancelled. * * @return if the event is cancelled */ - public boolean isCanceled(); + boolean isCancelled(); /** * Set whether or not for an event to be cancelled. */ - public void setCanceled(boolean cancel); + void setCancelled(boolean cancel); } diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index 72878fc..80e034d 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -21,7 +21,6 @@ import com.clubobsidian.trident.util.EventNode; import java.lang.reflect.Method; -import java.util.Iterator; import java.util.Map; import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; @@ -29,14 +28,14 @@ /** * Abstract class for implementing EventBus - * classes. For an example see @see com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus + * classes. For an example see @see com.clubobsidian.trident.eventbus.javassist.JavassistEventBus * * @author virustotalop */ public abstract class EventBus { - private Map> registeredEventListeners; - private Map, EventDoublyLinkedList> registeredExecutors; + private final Map> registeredEventListeners; + private final Map, EventDoublyLinkedList> registeredExecutors; public EventBus() { this.registeredEventListeners = new ConcurrentHashMap<>(); @@ -64,9 +63,9 @@ public boolean callEvent(final Event event) { } while (node != null) { MethodExecutor executor = node.getData(); - if (event instanceof Cancelable) { - Cancelable cancelable = (Cancelable) event; - if (cancelable.isCanceled() && executor.isIgnoringCanceled()) { + if (event instanceof Cancellable) { + Cancellable cancellable = (Cancellable) event; + if (cancellable.isCancelled() && executor.isIgnoringCancelled()) { node = node.getNext(); continue; } @@ -85,7 +84,7 @@ public boolean callEvent(final Event event) { public boolean registerEvents(final Object listener) { if (listener == null) { return false; - } else if (this.registeredEventListeners.keySet().contains(listener)) { + } else if (this.registeredEventListeners.containsKey(listener)) { return false; } @@ -102,11 +101,12 @@ public boolean registerEvents(final Object listener) { this.registeredEventListeners.put(listener, new ConcurrentLinkedQueue<>()); } - boolean ignoreCanceled = handler.ignoreCanceled(); - MethodExecutor executor = this.createMethodExecutor(listener, method, ignoreCanceled); + boolean ignoreCancelled = handler.ignoreCancelled(); + MethodExecutor executor = this.createMethodExecutor(listener, method, ignoreCancelled); - if (executor == null) + if (executor == null) { return false; + } this.registeredExecutors.get(eventClass).insert(executor, handler.priority()); this.registeredEventListeners.get(listener).add(executor); @@ -117,7 +117,7 @@ public boolean registerEvents(final Object listener) { return true; } - protected abstract MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled); + protected abstract MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCancelled); /** * @param listener listener to be unregistered @@ -129,9 +129,7 @@ public boolean unregisterEvents(Object listener) { return false; for (EventDoublyLinkedList list : this.registeredExecutors.values()) { - Iterator it = executors.iterator(); - while (it.hasNext()) { - MethodExecutor executor = it.next(); + for (MethodExecutor executor : executors) { list.remove(executor); } } diff --git a/src/main/java/com/clubobsidian/trident/EventHandler.java b/src/main/java/com/clubobsidian/trident/EventHandler.java index 89ff48f..6c94bcc 100644 --- a/src/main/java/com/clubobsidian/trident/EventHandler.java +++ b/src/main/java/com/clubobsidian/trident/EventHandler.java @@ -33,6 +33,6 @@ public @interface EventHandler { EventPriority priority() default EventPriority.NORMAL; - boolean ignoreCanceled() default false; + boolean ignoreCancelled() default false; } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/EventPriority.java b/src/main/java/com/clubobsidian/trident/EventPriority.java index 4387eb5..8c3e2c6 100644 --- a/src/main/java/com/clubobsidian/trident/EventPriority.java +++ b/src/main/java/com/clubobsidian/trident/EventPriority.java @@ -30,9 +30,9 @@ public enum EventPriority { HIGHEST(4), MONITOR(5); - private int value; + private final int value; - private EventPriority(final int value) { + EventPriority(final int value) { this.value = value; } diff --git a/src/main/java/com/clubobsidian/trident/MethodExecutor.java b/src/main/java/com/clubobsidian/trident/MethodExecutor.java index 256ed36..3d2501e 100644 --- a/src/main/java/com/clubobsidian/trident/MethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/MethodExecutor.java @@ -26,14 +26,14 @@ */ public abstract class MethodExecutor { - private Object listener; - private Method method; - private boolean ignoreCanceled; + private final Object listener; + private final Method method; + private final boolean ignoreCancelled; - public MethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + public MethodExecutor(Object listener, Method method, boolean ignoreCancelled) { this.listener = listener; this.method = method; - this.ignoreCanceled = ignoreCanceled; + this.ignoreCancelled = ignoreCancelled; } /** @@ -51,10 +51,10 @@ public Method getMethod() { } /** - * @return whether or not the method executor is ignoring canceled + * @return whether or not the method executor is ignoring cancelled */ - public boolean isIgnoringCanceled() { - return this.ignoreCanceled; + public boolean isIgnoringCancelled() { + return this.ignoreCancelled; } /** diff --git a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java index 273579c..2dd7e51 100644 --- a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java +++ b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java @@ -26,7 +26,7 @@ */ public class DeadEvent extends Event { - private Event event; + private final Event event; public DeadEvent(Event event) { this.event = event; diff --git a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java index 1f15726..7431da5 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java @@ -31,9 +31,9 @@ */ public class JavassistEventBus extends EventBus { - private static Map map = new ConcurrentHashMap<>(); + private static final Map map = new ConcurrentHashMap<>(); - private ClassPool pool; + private final ClassPool pool; public JavassistEventBus() { this.pool = new ClassPool(true); @@ -49,11 +49,11 @@ public ClassPool getClassPool() { } @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { - return this.generateMethodExecutor(listener, method, ignoreCanceled); + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCancelled) { + return this.generateMethodExecutor(listener, method, ignoreCancelled); } - private MethodExecutor generateMethodExecutor(Object listener, final Method method, final boolean ignoreCanceled) { + private MethodExecutor generateMethodExecutor(Object listener, final Method method, final boolean ignoreCancelled) { if (listener == null || method == null) { return null; } @@ -110,7 +110,7 @@ private MethodExecutor generateMethodExecutor(Object listener, final Method meth methodExecutorClass.addMethod(call); Class cl = methodExecutorClass.toClass(classLoader, JavassistEventBus.class.getProtectionDomain()); - return (MethodExecutor) cl.getDeclaredConstructors()[0].newInstance(listener, method, ignoreCanceled); + return (MethodExecutor) cl.getDeclaredConstructors()[0].newInstance(listener, method, ignoreCancelled); } catch (NotFoundException | CannotCompileException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException e) { e.printStackTrace(); } diff --git a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java index c5d5d82..928e251 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java @@ -11,9 +11,9 @@ public class MethodHandleEventBus extends EventBus { @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCancelled) { try { - return new MethodHandleExecutor(listener, method, ignoreCanceled); + return new MethodHandleExecutor(listener, method, ignoreCancelled); } catch (IllegalAccessException e) { e.printStackTrace(); } diff --git a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java index a3690d3..50f3a1c 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java @@ -5,7 +5,6 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** @@ -13,10 +12,10 @@ */ public class MethodHandleExecutor extends MethodExecutor { - private MethodHandle handle; + private final MethodHandle handle; - public MethodHandleExecutor(Object listener, Method method, boolean ignoreCanceled) throws IllegalAccessException { - super(listener, method, ignoreCanceled); + public MethodHandleExecutor(Object listener, Method method, boolean ignoreCancelled) throws IllegalAccessException { + super(listener, method, ignoreCancelled); this.handle = MethodHandles.lookup().unreflect(method); } diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java index 5e9effa..2e0f74f 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java @@ -26,7 +26,7 @@ public class ReflectionEventBus extends EventBus { @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { - return new ReflectionMethodExecutor(listener, method, ignoreCanceled); + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCancelled) { + return new ReflectionMethodExecutor(listener, method, ignoreCancelled); } } \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java index b4dcc93..91ebf6e 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java @@ -26,8 +26,8 @@ */ public class ReflectionMethodExecutor extends MethodExecutor { - public ReflectionMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { - super(listener, method, ignoreCanceled); + public ReflectionMethodExecutor(Object listener, Method method, boolean ignoreCancelled) { + super(listener, method, ignoreCancelled); } @Override diff --git a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java index 9b9e18b..46478a2 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -2,7 +2,7 @@ import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.test.impl.TestCancelableEvent; +import com.clubobsidian.trident.test.impl.TestCancellableEvent; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; import com.clubobsidian.trident.test.impl.TestOrderEvent; @@ -37,7 +37,7 @@ public void testEventCancellable() { EventBus manager = this.createNewEventBus(); manager.registerEvents(test); - manager.callEvent(new TestCancelableEvent()); + manager.callEvent(new TestCancellableEvent()); assertTrue("Test is not true, event was not cancelled", test.getTest()); } diff --git a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java b/src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java similarity index 81% rename from src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java rename to src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java index 7cd57ad..380c639 100644 --- a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java +++ b/src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java @@ -18,22 +18,22 @@ import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; -import com.clubobsidian.trident.test.impl.TestCancelableEvent; +import com.clubobsidian.trident.test.impl.TestCancellableEvent; import com.clubobsidian.trident.test.impl.TestListenerIgnore; import org.junit.Test; import static org.junit.Assert.assertTrue; -public class IgnoreCanceledTest { +public class IgnoreCancelledTest { @Test - public void ignoredCanceled() { + public void ignoredCancelled() { TestListenerIgnore listener = new TestListenerIgnore(); EventBus manager = new JavassistEventBus(); manager.registerEvents(listener); - manager.callEvent(new TestCancelableEvent()); + manager.callEvent(new TestCancellableEvent()); - assertTrue("Event was not canceled", listener.isCanceled()); + assertTrue("Event was not cancelled", listener.isCancelled()); assertTrue("Event was not ignored", listener.getIgnored()); } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java similarity index 69% rename from src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java index 74066ba..a3d8e90 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java @@ -15,18 +15,18 @@ */ package com.clubobsidian.trident.test.impl; -import com.clubobsidian.trident.Cancelable; +import com.clubobsidian.trident.Cancellable; -public class TestCancelableEvent extends TestEvent implements Cancelable { +public class TestCancellableEvent extends TestEvent implements Cancellable { - private boolean canceled; + private boolean cancelled; @Override - public boolean isCanceled() { - return this.canceled; + public boolean isCancelled() { + return this.cancelled; } - public void setCanceled(boolean cancelled) { - this.canceled = cancelled; + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; } } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java index 054e8a4..7e9fe4a 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java @@ -8,7 +8,7 @@ public class TestEventBus extends EventBus { @Override - protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCancelled) { return null; } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java index 9f3218f..ee76239 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java @@ -42,13 +42,13 @@ public void test(TestEvent event) { } @EventHandler - public void testCanceleable(TestCancelableEvent event) { - event.setCanceled(true); + public void testCanceleable(TestCancellableEvent event) { + event.setCancelled(true); } @EventHandler(priority = EventPriority.HIGHEST) - public void testCancelableHighest(TestCancelableEvent event) { - if (event.isCanceled()) { + public void testCancelableHighest(TestCancellableEvent event) { + if (event.isCancelled()) { this.test = true; } } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java index bf26d6c..be504c7 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java @@ -20,11 +20,11 @@ public class TestListenerIgnore { - private boolean canceled = false; + private boolean cancelled = false; private boolean ignored = true; - public boolean isCanceled() { - return this.canceled; + public boolean isCancelled() { + return this.cancelled; } public boolean getIgnored() { @@ -32,13 +32,13 @@ public boolean getIgnored() { } @EventHandler - public void setCanceled(TestCancelableEvent e) { - e.setCanceled(true); - this.canceled = true; + public void setCancelled(TestCancellableEvent e) { + e.setCancelled(true); + this.cancelled = true; } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCanceled = true) - public void test(TestCancelableEvent e) { + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void test(TestCancellableEvent e) { this.ignored = false; } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java index e4de204..c25339a 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java @@ -7,8 +7,8 @@ public class TestMethodExecutor extends MethodExecutor { - public TestMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { - super(listener, method, ignoreCanceled); + public TestMethodExecutor(Object listener, Method method, boolean ignoreCancelled) { + super(listener, method, ignoreCancelled); } @Override From cd10674a9df4f6df2455c12f5ead3e6265a89868 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Fri, 2 Apr 2021 08:05:55 -0700 Subject: [PATCH 4/5] Update copyright to 2021 --- LICENSE_HEADER | 2 +- .../com/clubobsidian/trident/Cancellable.java | 30 +++++++++---------- .../java/com/clubobsidian/trident/Event.java | 30 +++++++++---------- .../com/clubobsidian/trident/EventBus.java | 30 +++++++++---------- .../clubobsidian/trident/EventHandler.java | 30 +++++++++---------- .../clubobsidian/trident/EventPriority.java | 30 +++++++++---------- .../clubobsidian/trident/MethodExecutor.java | 30 +++++++++---------- .../clubobsidian/trident/event/DeadEvent.java | 30 +++++++++---------- .../eventbus/javassist/JavassistEventBus.java | 30 +++++++++---------- .../methodhandle/MethodHandleEventBus.java | 16 ++++++++++ .../methodhandle/MethodHandleExecutor.java | 16 ++++++++++ .../trident/eventbus/package-info.java | 16 ++++++++++ .../reflection/ReflectionEventBus.java | 30 +++++++++---------- .../reflection/ReflectionMethodExecutor.java | 30 +++++++++---------- .../clubobsidian/trident/util/ClassUtil.java | 30 +++++++++---------- .../trident/util/EventDoublyLinkedList.java | 30 +++++++++---------- .../clubobsidian/trident/util/EventNode.java | 29 +++++++++--------- .../trident/test/DeadEventTest.java | 16 ++++++++++ .../trident/test/EventBusTest.java | 16 ++++++++++ .../test/EventDoublyLinkedListTest.java | 30 +++++++++---------- .../trident/test/EventPriorityTest.java | 16 ++++++++++ .../clubobsidian/trident/test/EventTest.java | 16 ++++++++++ .../trident/test/IgnoreCancelledTest.java | 30 +++++++++---------- .../trident/test/JavaAssistEventBusTest.java | 30 +++++++++---------- .../test/MethodHandleEventBusTest.java | 30 +++++++++---------- .../trident/test/MultiThreadingTest.java | 16 ++++++++++ .../trident/test/OtherEventBusTest.java | 16 ++++++++++ .../trident/test/ReflectionEventBusTest.java | 30 +++++++++---------- .../trident/test/ReflectionMiscEventTest.java | 30 +++++++++---------- .../clubobsidian/trident/test/UtilTest.java | 30 +++++++++---------- .../test/impl/TestCancellableEvent.java | 30 +++++++++---------- .../test/impl/TestDeadEventListener.java | 16 ++++++++++ .../trident/test/impl/TestEvent.java | 30 +++++++++---------- .../trident/test/impl/TestEventBus.java | 16 ++++++++++ .../trident/test/impl/TestEventSuper.java | 30 +++++++++---------- .../trident/test/impl/TestListener.java | 30 +++++++++---------- .../trident/test/impl/TestListenerIgnore.java | 30 +++++++++---------- .../trident/test/impl/TestMethodExecutor.java | 16 ++++++++++ .../trident/test/impl/TestOrderEvent.java | 30 +++++++++---------- .../test/impl/TestWrongArgumentEvent.java | 16 ++++++++++ .../test/impl/TestWrongArgumentListener.java | 30 +++++++++---------- 41 files changed, 614 insertions(+), 405 deletions(-) diff --git a/LICENSE_HEADER b/LICENSE_HEADER index ad0340b..53369bc 100644 --- a/LICENSE_HEADER +++ b/LICENSE_HEADER @@ -1,4 +1,4 @@ - Copyright 2019 Club Obsidian and contributors. + Copyright 2021 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/Cancellable.java b/src/main/java/com/clubobsidian/trident/Cancellable.java index 4435bf5..8a68a34 100644 --- a/src/main/java/com/clubobsidian/trident/Cancellable.java +++ b/src/main/java/com/clubobsidian/trident/Cancellable.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident; /** diff --git a/src/main/java/com/clubobsidian/trident/Event.java b/src/main/java/com/clubobsidian/trident/Event.java index d6c82fb..bf7796a 100644 --- a/src/main/java/com/clubobsidian/trident/Event.java +++ b/src/main/java/com/clubobsidian/trident/Event.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident; /** diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index 80e034d..0da71f4 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident; import com.clubobsidian.trident.event.DeadEvent; diff --git a/src/main/java/com/clubobsidian/trident/EventHandler.java b/src/main/java/com/clubobsidian/trident/EventHandler.java index 6c94bcc..66f2c26 100644 --- a/src/main/java/com/clubobsidian/trident/EventHandler.java +++ b/src/main/java/com/clubobsidian/trident/EventHandler.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident; import java.lang.annotation.ElementType; diff --git a/src/main/java/com/clubobsidian/trident/EventPriority.java b/src/main/java/com/clubobsidian/trident/EventPriority.java index 8c3e2c6..69ebf3b 100644 --- a/src/main/java/com/clubobsidian/trident/EventPriority.java +++ b/src/main/java/com/clubobsidian/trident/EventPriority.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident; /** diff --git a/src/main/java/com/clubobsidian/trident/MethodExecutor.java b/src/main/java/com/clubobsidian/trident/MethodExecutor.java index 3d2501e..4557139 100644 --- a/src/main/java/com/clubobsidian/trident/MethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/MethodExecutor.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident; import java.lang.reflect.Method; diff --git a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java index 2dd7e51..de48e28 100644 --- a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java +++ b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.event; import com.clubobsidian.trident.Event; diff --git a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java index 7431da5..589f87c 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.eventbus.javassist; import com.clubobsidian.trident.Event; diff --git a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java index 928e251..9e46284 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleEventBus.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.eventbus.methodhandle; import com.clubobsidian.trident.EventBus; diff --git a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java index 50f3a1c..364f715 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/methodhandle/MethodHandleExecutor.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.eventbus.methodhandle; import com.clubobsidian.trident.Event; diff --git a/src/main/java/com/clubobsidian/trident/eventbus/package-info.java b/src/main/java/com/clubobsidian/trident/eventbus/package-info.java index 857b273..a9f3400 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/package-info.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/package-info.java @@ -1 +1,17 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.eventbus; \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java index 2e0f74f..06df6c0 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.eventbus.reflection; import com.clubobsidian.trident.EventBus; diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java index 91ebf6e..b2ec6d1 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.eventbus.reflection; import com.clubobsidian.trident.Event; diff --git a/src/main/java/com/clubobsidian/trident/util/ClassUtil.java b/src/main/java/com/clubobsidian/trident/util/ClassUtil.java index cc3545c..ce2a4b8 100644 --- a/src/main/java/com/clubobsidian/trident/util/ClassUtil.java +++ b/src/main/java/com/clubobsidian/trident/util/ClassUtil.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.util; import com.clubobsidian.trident.Event; diff --git a/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java b/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java index 4101107..e00a981 100644 --- a/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java +++ b/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.util; import com.clubobsidian.trident.EventPriority; diff --git a/src/main/java/com/clubobsidian/trident/util/EventNode.java b/src/main/java/com/clubobsidian/trident/util/EventNode.java index 6dfebee..9a3bc0f 100644 --- a/src/main/java/com/clubobsidian/trident/util/EventNode.java +++ b/src/main/java/com/clubobsidian/trident/util/EventNode.java @@ -1,17 +1,18 @@ -/* Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.util; import com.clubobsidian.trident.MethodExecutor; diff --git a/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java b/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java index 095f6db..54f45c7 100644 --- a/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; diff --git a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java index 46478a2..759dba5 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test; import com.clubobsidian.trident.Event; diff --git a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java index c312d61..8a55ab6 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventPriority; diff --git a/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java b/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java index ea6e107..9bdf7c9 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventPriority; diff --git a/src/test/java/com/clubobsidian/trident/test/EventTest.java b/src/test/java/com/clubobsidian/trident/test/EventTest.java index 455e855..97c889c 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test; import com.clubobsidian.trident.Event; diff --git a/src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java b/src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java index 380c639..741176f 100644 --- a/src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java +++ b/src/test/java/com/clubobsidian/trident/test/IgnoreCancelledTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index c9084bb..230f779 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; diff --git a/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java index 5d3c1e1..fa9531a 100644 --- a/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/MethodHandleEventBusTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; diff --git a/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java b/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java index 5e9d19f..a9ce74e 100644 --- a/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java +++ b/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventPriority; diff --git a/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java index 2d3f860..b7cf0d6 100644 --- a/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java index 1a38106..0e7c556 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index 3d4cf4a..d2958f6 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; diff --git a/src/test/java/com/clubobsidian/trident/test/UtilTest.java b/src/test/java/com/clubobsidian/trident/test/UtilTest.java index bd46b16..50d7794 100644 --- a/src/test/java/com/clubobsidian/trident/test/UtilTest.java +++ b/src/test/java/com/clubobsidian/trident/test/UtilTest.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test; import com.clubobsidian.trident.Event; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java index a3d8e90..9d6e524 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestCancellableEvent.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Cancellable; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java index 65f4147..7d57714 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.EventHandler; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java index 3ace3da..5dd1408 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; /** diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java index 7e9fe4a..ef969bc 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.EventBus; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java index d7165fd..ec3fef2 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Event; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java index ee76239..9b68957 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.EventHandler; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java index be504c7..ded5297 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.EventHandler; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java index c25339a..cf593ba 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Event; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java index acf0975..7f89657 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Event; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java index fa15ccf..484cc2e 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.clubobsidian.trident.test.impl; public class TestWrongArgumentEvent extends TestEventSuper { diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java index 9eab9f4..ee328bd 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java @@ -1,18 +1,18 @@ -/* - Copyright 2019 Club Obsidian and contributors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +/* + * Copyright 2021 Club Obsidian and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.clubobsidian.trident.test.impl; public class TestWrongArgumentListener { From b2e2b74af3077533d3ec06f0302abfc81ba6d1cf Mon Sep 17 00:00:00 2001 From: virustotalop Date: Fri, 2 Apr 2021 08:07:02 -0700 Subject: [PATCH 5/5] Prepare 3.0.0 release --- README.md | 6 +++--- build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3e9129e..d1b473b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Known Vulnerabilities](https://snyk.io//test/github/ClubObsidian/trident/badge.svg?targetFile=build.gradle)](https://snyk.io//test/github/ClubObsidian/trident?targetFile=build.gradle) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Discord](https://img.shields.io/discord/482823104905609248.svg?logo=discord)](https://discord.gg/EY5Tq6r) -[![javadocs](https://img.shields.io/badge/Javadocs-2.1.0-success.svg)](https://jitpack.io/com/github/clubobsidian/trident/2.1.0/javadoc/) +[![javadocs](https://img.shields.io/badge/Javadocs-3.0.0-success.svg)](https://jitpack.io/com/github/clubobsidian/trident/3.0.0/javadoc/) A dead simpile annotation-based event bus that allows different event executor implementations. @@ -33,7 +33,7 @@ repositories { maven { url 'https://jitpack.io' } } -compile 'com.github.clubobsidian:trident:2.1.0' +compile 'com.github.clubobsidian:trident:3.0.0' ``` ### Maven @@ -49,7 +49,7 @@ compile 'com.github.clubobsidian:trident:2.1.0' com.github.clubobsidian trident - 2.1.0 + 3.0.0 ``` diff --git a/build.gradle b/build.gradle index b57b573..2956444 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ sourceCompatibility = 1.8 targetCompatibility = 1.8 group = 'com.clubobsidian' -version = '2.0.0' +version = '3.0.0' repositories { mavenCentral()