/** * Create a new instance from a string representation. e.g. {@code "42", "-1"} */ public Revision(String revisionStr) { requireNonNull(revisionStr, "revisionStr"); if ("head".equalsIgnoreCase(revisionStr) || "-1".equals(revisionStr)) { major = HEAD.major; } else { if (!REVISION_PATTERN.matcher(revisionStr).matches()) { throw illegalRevisionArgumentException(revisionStr); } try { major = Integer.parseInt( !revisionStr.endsWith(".0") ? revisionStr : revisionStr.substring(0, revisionStr.length() - 2)); if (major == 0) { throw illegalRevisionArgumentException(revisionStr); } } catch (NumberFormatException ignored) { throw illegalRevisionArgumentException(revisionStr); } } text = generateText(major); }
/** * Create a new instance from a string representation. e.g. {@code "42", "-1"} */ public Revision(String revisionStr) { requireNonNull(revisionStr, "revisionStr"); if ("head".equalsIgnoreCase(revisionStr) || "-1".equals(revisionStr)) { major = HEAD.major; } else { if (!REVISION_PATTERN.matcher(revisionStr).matches()) { throw illegalRevisionArgumentException(revisionStr); } try { major = Integer.parseInt( !revisionStr.endsWith(".0") ? revisionStr : revisionStr.substring(0, revisionStr.length() - 2)); if (major == 0) { throw illegalRevisionArgumentException(revisionStr); } } catch (NumberFormatException ignored) { throw illegalRevisionArgumentException(revisionStr); } } text = generateText(major); }
/** * Create a new instance from a string representation. e.g. {@code "42", "-1"} */ public Revision(String revisionStr) { requireNonNull(revisionStr, "revisionStr"); if ("head".equalsIgnoreCase(revisionStr) || "-1".equals(revisionStr)) { major = HEAD.major; } else { if (!REVISION_PATTERN.matcher(revisionStr).matches()) { throw illegalRevisionArgumentException(revisionStr); } try { major = Integer.parseInt( !revisionStr.endsWith(".0") ? revisionStr : revisionStr.substring(0, revisionStr.length() - 2)); if (major == 0) { throw illegalRevisionArgumentException(revisionStr); } } catch (NumberFormatException ignored) { throw illegalRevisionArgumentException(revisionStr); } } text = generateText(major); }