Interface HasState

All Known Subinterfaces:
CEDigraph, Collection, CollectionOfFreezables, Freezable, FreezableColorString, FreezableSet, FreezableString, GEDigraph, List, Map, MapToFreezables, MutableCEDigraph, MutableCollection, MutableCollectionOfFreezables, MutableGEDigraph, MutableList, MutableMap, MutableMapToFreezables, MutableSet, MutableSetOfFreezables, MutableUEDigraph, Set, SetOfFreezables, UEDigraph
All Known Implementing Classes:
AbstractArrayList, AbstractFreezerHashMap, AbstractFreezerHashSet, AbstractHashCEDigraph, AbstractHashGEDigraph, AbstractHashMap, AbstractHashMapToFreezables, AbstractHashSet, AbstractHashSetOfFreezables, AbstractHashUEDigraph, ColorStringBean, DelegatingMutableSet, FreezableDelegatingMutableSet, JDBCBackedMutableSet, MemSet, MutableArrayList, MutableFreezerHashMap, MutableFreezerHashSet, MutableHashCEDigraph, MutableHashGEDigraph, MutableHashMap, MutableHashMapToFreezables, MutableHashSet, MutableHashSetOfFreezables, MutableHashUEDigraph, SoftHashMap, StringBean, TestBean, TestBean

public interface HasState

Classes of objects that have an internal state should implement this interface as a better alternative to overriding equals(). The equals() method will be able to keep its original function: identifying objects which are the same instance.

David Walend

Method Summary
 java.lang.Class getPrincipleInterface()
          Returns the class's principle interface for state comparisons.
 boolean sameStateAs(HasState victem)
          If two HasStates have the same internal state, return true.

Method Detail


public java.lang.Class getPrincipleInterface()
Returns the class's principle interface for state comparisons. If two objects have different principle interfaces, they never have the same state.


public boolean sameStateAs(HasState victem)
If two HasStates have the same internal state, return true.

For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.

Copyright (c) 2000, 2001, David Walend