Class ImmutableMultiList.ListView

All Implemented Interfaces:
Serializable, Iterable, Collection, List, SequencedCollection
Enclosing class:
ImmutableMultiList

protected class ImmutableMultiList.ListView extends WrapperCollections.AbstractWrapperList
ListView exposes the underlying ImmutableMultiList through the List interface, maintaining correct equals() and hashCode() semantics
See Also:
  • Constructor Details

    • ListView

      protected ListView()
      Create a ListView over this ImmutableMultiList.
  • Method Details

    • equals

      public boolean equals(Object o)
      Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.
      Specified by:
      equals in interface Collection
      Specified by:
      equals in interface List
      Overrides:
      equals in class WrapperCollections.AbstractWrapperCollection
      Parameters:
      o - the object to be compared for equality with this list.
      Returns:
      true if the specified object is equal to this list.
    • hashCode

      public int hashCode()
      Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
        hashCode = 1;
        Iterator i = list.iterator();
        while (i.hasNext()) {
            Object obj = i.next();
            hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
        }
       
      This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.
      Specified by:
      hashCode in interface Collection
      Specified by:
      hashCode in interface List
      Overrides:
      hashCode in class WrapperCollections.AbstractWrapperCollection
      Returns:
      the hash code value for this list.
      See Also: