Revision implements CacheValue { public static Revision fromString(String rev) { boolean isBranch = rev.charAt(0) == 'b'; int idx = isBranch ? 2 : 1; if (rev.charAt(idx - 1) != 'r') { throw new IllegalArgumentException(rev); } int len = rev.length(); long timestamp = 0; for (; idx < len; idx++) { char c = rev.charAt(idx); if (c == '-') { break; } int digit = c >= 'a'? c - 'a' + 10 : c - '0'; timestamp = (timestamp << 4) + digit; } int counter = 0; for (idx++; idx < len; idx++) { char c = rev.charAt(idx); if (c == '-') { break; } int digit = c >= 'a' ? c - 'a' + 10 : c - '0'; counter = (counter << 4) + digit; } int clusterId = 0; for (idx++; idx < len; idx++) { char c = rev.charAt(idx); int digit = c >= 'a' ? c - 'a' + 10 : c - '0'; clusterId = (clusterId << 4) + digit; } return new Revision(timestamp, counter, clusterId, isBranch); } Revision(long timestamp, int counter, int clusterId);  Revision(long timestamp, int counter, int clusterId, boolean branch); static long getCurrentTimestamp(); static long getTimestampDifference(Revision r1, Revision r2); static Revision fromString(String rev); @Override String toString(); StringBuilder toStringBuilder(StringBuilder sb); String toReadableString(); long getTimestamp(); int getCounter(); boolean isBranch(); Revision asBranchRevision(); Revision asTrunkRevision(); @Override int hashCode(); @Override boolean equals(Object other); int getClusterId(); @Override int getMemory();  }
@Test public void invalid() { for(String s : "1234,b,bb,".split(",")) { try { Revision.fromString(s); fail("Expected: Invalid revision id exception for " + s); } catch (Exception expected) { } } }