Class ListenerEntry
- java.lang.Object
-
- io.github.stasgora.observetree.listener.ListenerEntry
-
- All Implemented Interfaces:
java.lang.Comparable<ListenerEntry>
public class ListenerEntry extends java.lang.Object implements java.lang.Comparable<ListenerEntry>
Internal data class holding listener reference together with its priority. Overrides standard methods that ensure proper aggregation in collections.- Author:
- Stanisław Góra
- See Also:
ChangeListener
-
-
Field Summary
Fields Modifier and Type Field Description ChangeListener
listener
Listener callback method referenceint
priority
Listener priority
-
Constructor Summary
Constructors Constructor Description ListenerEntry(ChangeListener listener, int priority)
Constructs new listener entry object
-
Method Summary
Modifier and Type Method Description int
compareTo(ListenerEntry o)
Compares the specified object with thisListenerEntry
.boolean
equals(java.lang.Object o)
Compares the specified object with thisListenerEntry
for equality.int
hashCode()
Returns the hash code value for thisListenerEntry
.
-
-
-
Field Detail
-
listener
public ChangeListener listener
Listener callback method reference
-
priority
public int priority
Listener priority
-
-
Constructor Detail
-
ListenerEntry
public ListenerEntry(ChangeListener listener, int priority)
Constructs new listener entry object- Parameters:
listener
- listener callback method referencepriority
- listener priority
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
Compares the specified object with thisListenerEntry
for equality. Returns true if the given object is also aListenerEntry
and the two have the samelistener
reference andpriority
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- object to be compared for equality with thisListenerEntry
- Returns:
true
if the specified object is equal to thisListenerEntry
-
hashCode
public int hashCode()
Returns the hash code value for thisListenerEntry
. It is defined by the hashes of thepriority
andlistener
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code value for this
ListenerEntry
-
compareTo
public int compareTo(ListenerEntry o)
Compares the specified object with thisListenerEntry
. It sorts the objects in a descending order according to theirpriority
.- Specified by:
compareTo
in interfacejava.lang.Comparable<ListenerEntry>
- Parameters:
o
-ListenerEntry
to which thisListenerEntry
is to be compared- Returns:
- -1 or 1 as this
ListenerEntry
should be placed before or behindo
or 0 if the objects are equal.
-
-