//(c):Benja Fallenstein package gzz.storm.util; import gzz.util.*; import java.util.*; /** A simple mock implementation of Version, for testing. * This version stores a single integer and * the corresponding diff stores the numeric difference * between the old and the new version. A VersionFormat * that formats the integer as ASCII is included. */ public class TestVersion implements Version { public final int value; public TestVersion(int value) { this.value = value; } public Version.Diff getDiffFrom(Version v0) { TestVersion v = (TestVersion)v0; return new Diff(value - v.value); } public boolean equals(Object o) { if(!(o instanceof TestVersion)) return false; return ((TestVersion)o).value == value; } public int hashCode() { return 16236^value; } public static class Diff implements Version.Diff { public final int diff; public Diff(int diff) { this.diff = diff; } public Version.Diff inverse() { return new Diff(-diff); } public Version applyTo(Version v0) { TestVersion v = (TestVersion)v0; return new TestVersion(v.value + diff); } public boolean isEmpty() { return diff == 0; } public boolean equals(Object o) { if(!(o instanceof Diff)) return false; return ((Diff)o).diff == diff; } public int hashCode() { return 138789^diff; } } }