Class ListenerEntry

  • All Implemented Interfaces:
    Comparable<ListenerEntry>

    public class ListenerEntry
    extends Object
    implements 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 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 reference
        priority - listener priority
    • Method Detail

      • equals

        public boolean equals​(Object o)
        Compares the specified object with this ListenerEntry for equality. Returns true if the given object is also a ListenerEntry and the two have the same listener reference and priority
        Overrides:
        equals in class Object
        Parameters:
        o - object to be compared for equality with this ListenerEntry
        Returns:
        true if the specified object is equal to this ListenerEntry
      • hashCode

        public int hashCode()
        Returns the hash code value for this ListenerEntry. It is defined by the hashes of the priority and listener.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code value for this ListenerEntry
      • compareTo

        public int compareTo​(ListenerEntry o)
        Compares the specified object with this ListenerEntry. It sorts the objects in a descending order according to their priority.
        Specified by:
        compareTo in interface Comparable<ListenerEntry>
        Parameters:
        o - ListenerEntry to which this ListenerEntry is to be compared
        Returns:
        -1 or 1 as this ListenerEntry should be placed before or behind o or 0 if the objects are equal.