Skip to content

Commit

Permalink
Add missing Javadoc to ListenerList
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 13, 2024
1 parent 0c97368 commit 42348a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs CT_CONSTRUCTOR_THROW in Base64 by implementing finalize() as a noop to avoid finalizer attacks.</action>
<action type="fix" dev="ggregory" due-to="Andreas Lemke, Gary Gregory">Increase message limit in IMAPReply.TAGGED_RESPONSE from 80 to 500 characters.</action>
<action type="fix" dev="ggregory" due-to="Andreas Lemke, Gary Gregory">Increase message limit in IMAPReply.UNTAGGED_RESPONSE from 160 to 500 characters.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Add missing Javadoc to ListenerList.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">org.apache.commons.net.nntp.Article#getChild().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">org.apache.commons.net.nntp.Article#getNext().</action>
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/apache/commons/net/util/ListenerList.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,27 @@ public class ListenerList implements Serializable, Iterable<EventListener> {

private final CopyOnWriteArrayList<EventListener> listeners;

/**
* Constructs a new instance.
*/
public ListenerList() {
listeners = new CopyOnWriteArrayList<>();
}

/**
* Adds the given listener to the end of this list.
*
* @param listener A listener.
*/
public void addListener(final EventListener listener) {
listeners.add(listener);
}

/**
* Gets the number of elements in this list.
*
* @return the number of elements in this list
*/
public int getListenerCount() {
return listeners.size();
}
Expand All @@ -60,7 +73,9 @@ private void readObject(final ObjectInputStream ignored) {
}

/**
* Serialization is unnecessary for this class. Reject attempts to do so until such time as the Serializable attribute can be dropped.
* Removes the first occurrence of the specified listener from this list, if it is present.
*
* @param listener listener to be removed from this list, if present.
*/
public void removeListener(final EventListener listener) {
listeners.remove(listener);
Expand Down

0 comments on commit 42348a5

Please sign in to comment.