Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


com.tangosol.util
Class ImmutableArrayList.SetView

java.lang.Object
  extended by com.tangosol.util.WrapperCollections.AbstractWrapperCollection
      extended by com.tangosol.util.WrapperCollections.AbstractWrapperSet
          extended by com.tangosol.util.ImmutableArrayList.SetView

All Implemented Interfaces:
Iterable, Collection, Set
Enclosing class:
ImmutableArrayList

protected class ImmutableArrayList.SetView
extends WrapperCollections.AbstractWrapperSet

SetView exposes the underlying ImmutableArrayList through the Set interface, maintaining correct equals() and hashCode() semantics


Field Summary

 

Fields inherited from class com.tangosol.util.WrapperCollections.AbstractWrapperCollection
m_colDelegate

 

Constructor Summary
protected ImmutableArrayList.SetView()
          Create a SetView over this ImmutableArrayList.

 

Method Summary
 boolean equals(Object o)
          Compares the specified object with this collection for equality.

While the Collection interface adds no stipulations to the general contract for the Object.equals, programmers who implement the Collection interface "directly" (in other words, create a class that is a Collection but is not a Set or a List) must exercise care if they choose to override the Object.equals. It is not necessary to do so, and the simplest course of action is to rely on Object's implementation, but the implementer may wish to implement a "value comparison" in place of the default "reference comparison." (The List and Set interfaces mandate such value comparisons.)

The general contract for the Object.equals method states that equals must be symmetric (in other words, a.equals(b) if and only if b.equals(a)). The contracts for List.equals and Set.equals state that lists are only equal to other lists, and sets to other sets. Thus, a custom equals method for a collection class that implements neither the List nor Set interface must return false when this collection is compared to any list or set. (By the same logic, it is not possible to write a class that correctly implements both the Set and List interfaces.)

 int hashCode()
          Returns the hash code value for this collection. While the Collection interface adds no stipulations to the general contract for the Object.hashCode method, programmers should take note that any class that overrides the Object.equals method must also override the Object.hashCode method in order to satisfy the general contract for the Object.hashCodemethod. In particular, c1.equals(c2) implies that c1.hashCode()==c2.hashCode().
 String toString()
          

 

Methods inherited from class com.tangosol.util.WrapperCollections.AbstractWrapperSet
getDelegate

 

Methods inherited from class com.tangosol.util.WrapperCollections.AbstractWrapperCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

 

Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

 

Constructor Detail

ImmutableArrayList.SetView

protected ImmutableArrayList.SetView()
Create a SetView over this ImmutableArrayList.

Method Detail

equals

public boolean equals(Object o)
Compares the specified object with this collection for equality.

While the Collection interface adds no stipulations to the general contract for the Object.equals, programmers who implement the Collection interface "directly" (in other words, create a class that is a Collection but is not a Set or a List) must exercise care if they choose to override the Object.equals. It is not necessary to do so, and the simplest course of action is to rely on Object's implementation, but the implementer may wish to implement a "value comparison" in place of the default "reference comparison." (The List and Set interfaces mandate such value comparisons.)

The general contract for the Object.equals method states that equals must be symmetric (in other words, a.equals(b) if and only if b.equals(a)). The contracts for List.equals and Set.equals state that lists are only equal to other lists, and sets to other sets. Thus, a custom equals method for a collection class that implements neither the List nor Set interface must return false when this collection is compared to any list or set. (By the same logic, it is not possible to write a class that correctly implements both the Set and List interfaces.)

Specified by:
equals in interface Collection
Specified by:
equals in interface Set
Overrides:
equals in class WrapperCollections.AbstractWrapperCollection
Parameters:
o - Object to be compared for equality with this collection.
Returns:
true if the specified object is equal to this collection
See Also:
Object.equals(Object), Set.equals(Object), List.equals(Object)

hashCode

public int hashCode()
Returns the hash code value for this collection. While the Collection interface adds no stipulations to the general contract for the Object.hashCode method, programmers should take note that any class that overrides the Object.equals method must also override the Object.hashCode method in order to satisfy the general contract for the Object.hashCodemethod. In particular, c1.equals(c2) implies that c1.hashCode()==c2.hashCode().
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface Set
Overrides:
hashCode in class WrapperCollections.AbstractWrapperCollection
Returns:
the hash code value for this collection
See Also:
Object.hashCode(), Object.equals(Object)

toString

public String toString()

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.