org.eigenbase.jmi
Class JmiCorrespondence

java.lang.Object
  extended by org.eigenbase.jmi.JmiCorrespondence

public class JmiCorrespondence
extends Object

JmiCorrespondence keeps track of the correspondence between a "before" version of a set of objects and an "after" version of the same set.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/jmi/JmiCorrespondence.java#7 $
Author:
John V. Sichi

Field Summary
private  Set<RefObject> additionSet
           
private  Map<RefObject,RefObject> afterToBeforeMap
           
private  Map<RefObject,RefObject> beforeToAfterMap
           
private  Set<RefObject> deletionSet
           
 
Constructor Summary
JmiCorrespondence()
          Creates a new correspondence (initially empty).
 
Method Summary
 void addMapping(RefObject beforeVersion, RefObject afterVersion)
          Creates a mapping between a "before" version of an object and its corresponding "after" version.
 void augmentBeforeSet(Collection<RefObject> objs)
          Adds a collection of "before" objects.
 Set<RefObject> getAdditionSet()
           
 Set<RefObject> getAfterSet()
           
 Set<RefObject> getBeforeSet()
           
 Set<RefObject> getDeletionSet()
           
 RefObject getMapping(RefObject obj)
          Looks up the mapping for an object version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beforeToAfterMap

private final Map<RefObject,RefObject> beforeToAfterMap

afterToBeforeMap

private final Map<RefObject,RefObject> afterToBeforeMap

additionSet

private final Set<RefObject> additionSet

deletionSet

private final Set<RefObject> deletionSet
Constructor Detail

JmiCorrespondence

public JmiCorrespondence()
Creates a new correspondence (initially empty).

Method Detail

addMapping

public void addMapping(RefObject beforeVersion,
                       RefObject afterVersion)
Creates a mapping between a "before" version of an object and its corresponding "after" version. One or the other side may be null (but not both); this indicates that the object only exists in one set or the other.

Parameters:
beforeVersion - "before" version to map
afterVersion - corresponding "after" version

getMapping

public RefObject getMapping(RefObject obj)
Looks up the mapping for an object version.

Parameters:
obj - object to look up (can be either version)
Returns:
corresponding version (before for after or vice versa), or null if no mapping exists

getBeforeSet

public Set<RefObject> getBeforeSet()
Returns:
"before" version of set

getAfterSet

public Set<RefObject> getAfterSet()
Returns:
"after" version of set

getAdditionSet

public Set<RefObject> getAdditionSet()
Returns:
set of "after" objects which have no corresponding "before" objects

getDeletionSet

public Set<RefObject> getDeletionSet()
Returns:
set of "before" objects which have no corresponding "after" objects

augmentBeforeSet

public void augmentBeforeSet(Collection<RefObject> objs)
Adds a collection of "before" objects. Objects already having mappings will be ignored. Others will be considered deletions.

Parameters:
objs - objects to add to "before" set