Revision implements Serializable, Comparable<Revision> { public static Revision parse(final String text) { if (text == null) { return UNDEFINED; } final String rev = text.trim(); if (isDateRevision(rev)) { try { final Date date = DateUtil.parseISO8601(trimDateBrackets(rev)); return create(date); } catch (IllegalArgumentException e) { return Revision.UNDEFINED; } } else if (isNumberRevision(rev)) { return create(Long.parseLong(rev)); } else if (isNamedRevision(rev)) { return HEAD; } else { return UNDEFINED; } } private  Revision(final long revisionNumber, final Date revisionDate, final boolean headRevision); static Revision create(final long revision); static Revision createHeadRevision(final long revision); static Revision create(final Date revision); static Revision create(final Date revision, final long revisionNumber); static Revision parse(final String text); long getNumber(); Date getDate(); @Override int compareTo(Revision o); boolean isHeadRevision(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final Revision FIRST; static final Revision UNDEFINED; static final Revision HEAD; }
@Test public void parseMalformedDateRevision() throws Exception { assertSame(Revision.UNDEFINED, Revision.parse("-r {foobar-not-applicable}")); }