Javadoc & whitespace

This commit is contained in:
Gary Gregory 2024-05-23 07:30:55 -04:00
parent 1e64e11e74
commit 73e5bac7fd

View File

@ -175,7 +175,7 @@ public static <T> EventListenerSupport<T> create(final Class<T> listenerInterfac
private transient L[] prototypeArray; private transient L[] prototypeArray;
/** /**
* Create a new EventListenerSupport instance. * Constructs a new EventListenerSupport instance.
* Serialization-friendly constructor. * Serialization-friendly constructor.
*/ */
private EventListenerSupport() { private EventListenerSupport() {
@ -219,10 +219,6 @@ public EventListenerSupport(final Class<L> listenerInterface, final ClassLoader
initializeTransientFields(listenerInterface, classLoader); initializeTransientFields(listenerInterface, classLoader);
} }
//**********************************************************************************************************************
// Other Methods
//**********************************************************************************************************************
/** /**
* Registers an event listener. * Registers an event listener.
* *
@ -236,7 +232,7 @@ public void addListener(final L listener) {
} }
/** /**
* Registers an event listener. Will not add a pre-existing listener * Registers an event listener. Will not add a pre-existing listener
* object to the list if {@code allowDuplicate} is false. * object to the list if {@code allowDuplicate} is false.
* *
* @param listener the event listener (may not be {@code null}). * @param listener the event listener (may not be {@code null}).
@ -254,8 +250,9 @@ public void addListener(final L listener, final boolean allowDuplicate) {
} }
/** /**
* Create the {@link InvocationHandler} responsible for broadcasting calls * Creates the {@link InvocationHandler} responsible for broadcasting calls
* to the managed listeners. Subclasses can override to provide custom behavior. * to the managed listeners. Subclasses can override to provide custom behavior.
*
* @return ProxyInvocationHandler * @return ProxyInvocationHandler
*/ */
protected InvocationHandler createInvocationHandler() { protected InvocationHandler createInvocationHandler() {
@ -263,7 +260,8 @@ protected InvocationHandler createInvocationHandler() {
} }
/** /**
* Create the proxy object. * Creates the proxy object.
*
* @param listenerInterface the class of the listener interface * @param listenerInterface the class of the listener interface
* @param classLoader the class loader to be used * @param classLoader the class loader to be used
*/ */
@ -285,7 +283,7 @@ public L fire() {
} }
/** /**
* Returns the number of registered listeners. * Gets the number of registered listeners.
* *
* @return the number of registered listeners. * @return the number of registered listeners.
*/ */
@ -304,7 +302,8 @@ public L[] getListeners() {
} }
/** /**
* Initialize transient fields. * Initializes transient fields.
*
* @param listenerInterface the class of the listener interface * @param listenerInterface the class of the listener interface
* @param classLoader the class loader to be used * @param classLoader the class loader to be used
*/ */
@ -315,7 +314,8 @@ private void initializeTransientFields(final Class<L> listenerInterface, final C
} }
/** /**
* Deserialize. * Deserializes.
*
* @param objectInputStream the input stream * @param objectInputStream the input stream
* @throws IOException if an IO error occurs * @throws IOException if an IO error occurs
* @throws ClassNotFoundException if the class cannot be resolved * @throws ClassNotFoundException if the class cannot be resolved
@ -323,11 +323,8 @@ private void initializeTransientFields(final Class<L> listenerInterface, final C
private void readObject(final ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { private void readObject(final ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
@SuppressWarnings("unchecked") // Will throw CCE here if not correct @SuppressWarnings("unchecked") // Will throw CCE here if not correct
final L[] srcListeners = (L[]) objectInputStream.readObject(); final L[] srcListeners = (L[]) objectInputStream.readObject();
this.listeners = new CopyOnWriteArrayList<>(srcListeners); this.listeners = new CopyOnWriteArrayList<>(srcListeners);
final Class<L> listenerInterface = ArrayUtils.getComponentType(srcListeners); final Class<L> listenerInterface = ArrayUtils.getComponentType(srcListeners);
initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader()); initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader());
} }
@ -345,13 +342,13 @@ public void removeListener(final L listener) {
} }
/** /**
* Serialize. * Serializes.
*
* @param objectOutputStream the output stream * @param objectOutputStream the output stream
* @throws IOException if an IO error occurs * @throws IOException if an IO error occurs
*/ */
private void writeObject(final ObjectOutputStream objectOutputStream) throws IOException { private void writeObject(final ObjectOutputStream objectOutputStream) throws IOException {
final ArrayList<L> serializableListeners = new ArrayList<>(); final ArrayList<L> serializableListeners = new ArrayList<>();
// don't just rely on instanceof Serializable: // don't just rely on instanceof Serializable:
ObjectOutputStream testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream()); ObjectOutputStream testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream());
for (final L listener : listeners) { for (final L listener : listeners) {