VersionCorrection implements ImmutableBean, Comparable<VersionCorrection>, Serializable { @FromString public static VersionCorrection parse(String versionCorrection) { ArgumentChecker.notEmpty(versionCorrection, "versionCorrection"); int posC = versionCorrection.indexOf(".C"); if (versionCorrection.charAt(0) != 'V' || posC < 0) { throw new IllegalArgumentException("Invalid identifier format: " + versionCorrection); } String verStr = versionCorrection.substring(1, posC); String corrStr = versionCorrection.substring(posC + 2); Instant versionAsOf = parseInstantString(verStr); Instant correctedTo = parseInstantString(corrStr); return of(versionAsOf, correctedTo); } @ImmutableConstructor private  VersionCorrection(Instant versionAsOf, Instant correctedTo); static VersionCorrection of(VersionCorrection versionCorrection); static VersionCorrection of(Instant versionAsOf, Instant correctedTo); static VersionCorrection ofVersionAsOf(Instant versionAsOf); static VersionCorrection ofCorrectedTo(Instant correctedTo); @FromString static VersionCorrection parse(String versionCorrection); static VersionCorrection parse(String versionAsOfString, String correctedToString); VersionCorrection withVersionAsOf(Instant versionAsOf); VersionCorrection withCorrectedTo(Instant correctedTo); boolean containsLatest(); VersionCorrection withLatestFixed(Instant now); String getVersionAsOfString(); String getCorrectedToString(); @Override int compareTo(VersionCorrection other); @Override @ToString String toString(); static VersionCorrection.Meta meta(); @Override VersionCorrection.Meta metaBean(); @Override Property<R> property(String propertyName); @Override Set<String> propertyNames(); Instant getVersionAsOf(); Instant getCorrectedTo(); @Override boolean equals(Object obj); @Override int hashCode(); static final VersionCorrection LATEST; }
@Test(dataProvider = "parseValid") public void test_parse_String(String first, String second, VersionCorrection expected) { VersionCorrection test = VersionCorrection.parse("V" + first + ".C" + second); assertEquals(expected, test); }
@Test(dataProvider = "parseValid") public void test_parse_StringString(String first, String second, VersionCorrection expected) { VersionCorrection test = VersionCorrection.parse(first, second); assertEquals(expected, test); }
@Test(dataProvider = "parseInvalid", expectedExceptions = IllegalArgumentException.class) public void test_parse_String_invalid(String input) { VersionCorrection.parse(input); }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_parse_StringString_invalid() { VersionCorrection.parse("LATS", "LATS"); }