gzz.slices
Class SliceVersion.Diff

java.lang.Object
  |
  +--gzz.slices.SliceVersion.Diff
All Implemented Interfaces:
java.io.Serializable, Version.Diff
Enclosing class:
SliceVersion

public static class SliceVersion.Diff
extends java.lang.Object
implements java.io.Serializable, Version.Diff

A diff between two SliceVersions.

See Also:
Serialized Form

Field Summary
 java.util.Set connects
          The set of Conn objects created by this diff.
 java.util.Map contents
          The cell contents set by this diff.
 java.util.Set disconnects
          The set of Conn objects removed by this diff.
 java.util.Map discontents
          The cell contents unset by this diff.
 
Constructor Summary
SliceVersion.Diff(java.util.Set connects, java.util.Set disconnects, java.util.Map contents, java.util.Map discontents)
          Create a new Diff by giving the fields of the object.
SliceVersion.Diff(SliceVersion old, SliceVersion nu)
          Create a new Diff by comparing an 'old' against a 'new' SliceVersion.
 
Method Summary
 Version applyTo(Version _old)
          Apply the diff to a SliceVersion and return the result.
 Version.Diff inverse()
          Return the inverse of this diff.
 boolean isEmpty()
          Whether this is the empty diff.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

connects

public final java.util.Set connects
The set of Conn objects created by this diff.


disconnects

public final java.util.Set disconnects
The set of Conn objects removed by this diff.


contents

public final java.util.Map contents
The cell contents set by this diff. The map has the same form as in SliceVersion.


discontents

public final java.util.Map discontents
The cell contents unset by this diff. The map has the same form as the connects map. This is the inverse of the contents map: if cell C had content A before and content B after the diff, C will be mapped to B in contents but to A in discontents.

Constructor Detail

SliceVersion.Diff

public SliceVersion.Diff(SliceVersion old,
                         SliceVersion nu)
Create a new Diff by comparing an 'old' against a 'new' SliceVersion. For all SliceVersions o and n, it must hold that: Diff(o, n).applyTo(o) == n and Diff(o, n).inverse().applyTo(n) == o.

Note: We do not do consistency checking because we believe the SliceVersions to be consistent, and our simple diffing algorithm to be sound.


SliceVersion.Diff

public SliceVersion.Diff(java.util.Set connects,
                         java.util.Set disconnects,
                         java.util.Map contents,
                         java.util.Map discontents)
Create a new Diff by giving the fields of the object. This is private because we do not check.

Method Detail

inverse

public Version.Diff inverse()
Return the inverse of this diff.

Specified by:
inverse in interface Version.Diff

applyTo

public Version applyTo(Version _old)
Apply the diff to a SliceVersion and return the result.

Specified by:
applyTo in interface Version.Diff

isEmpty

public boolean isEmpty()
Description copied from interface: Version.Diff
Whether this is the empty diff. It must hold that v.equals(diff.applyTo(v)) for all Versions v and Version.Diffs diff of the matching kind, iff diff.isEmpty().

We need this method because we never want to save empty diffs...

Specified by:
isEmpty in interface Version.Diff

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object