net.walend.collection
Interface HasState

All Known Subinterfaces:
Bag, CEDigraph, CEPath, Digraph, DigraphOfCEPaths, DigraphOfGEPaths, GEDigraph, GEPath, Grid, Grid2D, IndexedCEDigraph, IndexedDigraph, IndexedGEDigraph, IndexedMutableCEDigraph, IndexedMutableGEDigraph, MeasuredCEPath, MeasuredGEPath, MutableCEDigraph, MutableCEPath, MutableDigraphOfCEPaths, MutableDigraphOfGEPaths, MutableGEDigraph, MutableGEPath, MutableGrid, MutableGrid2D, MutableUEDigraph, MutableUEPath, Path, ShortestCEDistances, ShortestCEPaths, ShortestGEDistances, ShortestGEPaths, UEDigraph, UEPath
All Known Implementing Classes:
AbstractArrayGrid2D, AbstractDelegateDigraphOfCEPaths, AbstractDelegateDigraphOfCEPaths.DigraphCEPath, AbstractDelegateDigraphOfGEPaths, AbstractDelegateDigraphOfGEPaths.DigraphGEPath, AbstractHashCEDigraph, AbstractHashGEDigraph, AbstractHashUEDigraph, AbstractListCEPath, AbstractListGEPath, AbstractListUEPath, AbstractMapGrid2D, AbstractMatrixCEDigraph, AbstractMatrixGEDigraph, AbstractMatrixUEDigraph, AbstractShortestCEDistances, AbstractShortestCEPaths, AbstractShortestCEPaths.DigraphMeasuredCEPath, AbstractShortestGEDistances, AbstractShortestGEPaths, AbstractShortestGEPaths.DigraphMeasuredGEPath, CEBellmanFordTest, CEBellmanFordTest.BFCEDigraph, CEPathsFromShortestDistances, CEPathsFromShortestDistances.DigraphMeasuredCEPath, DijkstraShortestCEDistances, DijkstraShortestCEPaths, DijkstraShortestGEDistances, DijkstraShortestGEPaths, FloydWarshallShortestCEDistances, FloydWarshallShortestCEPaths, FloydWarshallShortestGEDistances, FloydWarshallShortestGEPaths, GEBellmanFordTest, GEBellmanFordTest.BFGEDigraph, ImmutableBag, JITShortestCEDistances, JITShortestCEPaths, JITShortestGEDistances, JITShortestGEPaths, JohnsonShortestCEDistances, JohnsonShortestCEPaths, JohnsonShortestGEDistances, JohnsonShortestGEPaths, MapBag, MutableArrayGrid2D, MutableHashCEDigraph, MutableHashGEDigraph, MutableHashUEDigraph, MutableListCEPath, MutableListGEPath, MutableListUEPath, MutableLMCEDigraph, MutableLMGEDigraph, MutableMapGrid2D, MutableMatrixCEDigraph, MutableMatrixGEDigraph, MutableMatrixUEDigraph, 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.

Author:
David Walend dfw1@cornell.edu

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

Method Detail

getPrincipleInterface

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.


sameStateAs

public boolean sameStateAs(HasState victim)
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) 2001, 2002, David Walend