DeweyVersion { public boolean isCompatible(DeweyVersion that) { if (this.length() > that.length()) { for (int i = 0; i < that.length(); i++) if (this.versions[i] != that.versions[i]) return false; return true; } else if (this.length() == that.length()) { int lastIndex = length() - 1; for (int i = 0; i < lastIndex; i++) if ( this.versions[i] != that.versions[i]) return false; return this.versions[lastIndex] >= that.versions[lastIndex]; } else { return false; } } DeweyVersion();  DeweyVersion(final int run);  DeweyVersion(final String version); private  DeweyVersion(int[] versions); DeweyVersion addRun(); DeweyVersion addRun(final int offset); int length(); boolean isCompatible(DeweyVersion that); DeweyVersion addStage(); @Override String toString();  }
@Test public void testPredecessor() { assertFalse(new DeweyVersion("1.0").isCompatible(new DeweyVersion("2.0"))); assertTrue(new DeweyVersion("1.0.0").isCompatible(new DeweyVersion("1.0"))); assertTrue(new DeweyVersion("1.1").isCompatible(new DeweyVersion("1.0"))); assertFalse(new DeweyVersion("1.0").isCompatible(new DeweyVersion("1.1"))); }