@Test public void checkParseVersion() { assertEquals(new SimpleVersion(1, null), SimpleVersion.parse("1")); assertEquals(new SimpleVersion(1, null), SimpleVersion.parse("1-test")); assertEquals(new SimpleVersion(1, 2), SimpleVersion.parse("1.2")); assertEquals(new SimpleVersion(1, 2), SimpleVersion.parse("1.2-test")); }
public final static SimpleVersion parse(final String version) throws IllegalArgumentException, NumberFormatException { StringTokenizer tokenizer = new StringTokenizer(version, "-"); if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException(version + " is not a valid Version"); } final String numbers = tokenizer.nextToken(); tokenizer = new StringTokenizer(numbers, "."); final Integer major = Integer.parseInt(tokenizer.nextToken()); Integer medium = null; if (tokenizer.hasMoreTokens()) { medium = Integer.parseInt(tokenizer.nextToken()); } return new SimpleVersion(major, medium); }
SimpleVersion implements Comparable<SimpleVersion>, Serializable { public final static SimpleVersion parse(final String version) throws IllegalArgumentException, NumberFormatException { StringTokenizer tokenizer = new StringTokenizer(version, "-"); if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException(version + " is not a valid Version"); } final String numbers = tokenizer.nextToken(); tokenizer = new StringTokenizer(numbers, "."); final Integer major = Integer.parseInt(tokenizer.nextToken()); Integer medium = null; if (tokenizer.hasMoreTokens()) { medium = Integer.parseInt(tokenizer.nextToken()); } return new SimpleVersion(major, medium); } }
SimpleVersion implements Comparable<SimpleVersion>, Serializable { public final static SimpleVersion parse(final String version) throws IllegalArgumentException, NumberFormatException { StringTokenizer tokenizer = new StringTokenizer(version, "-"); if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException(version + " is not a valid Version"); } final String numbers = tokenizer.nextToken(); tokenizer = new StringTokenizer(numbers, "."); final Integer major = Integer.parseInt(tokenizer.nextToken()); Integer medium = null; if (tokenizer.hasMoreTokens()) { medium = Integer.parseInt(tokenizer.nextToken()); } return new SimpleVersion(major, medium); } SimpleVersion(final Integer major, final Integer medium); }
SimpleVersion implements Comparable<SimpleVersion>, Serializable { public final static SimpleVersion parse(final String version) throws IllegalArgumentException, NumberFormatException { StringTokenizer tokenizer = new StringTokenizer(version, "-"); if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException(version + " is not a valid Version"); } final String numbers = tokenizer.nextToken(); tokenizer = new StringTokenizer(numbers, "."); final Integer major = Integer.parseInt(tokenizer.nextToken()); Integer medium = null; if (tokenizer.hasMoreTokens()) { medium = Integer.parseInt(tokenizer.nextToken()); } return new SimpleVersion(major, medium); } SimpleVersion(final Integer major, final Integer medium); final static SimpleVersion parse(final String version); static boolean isCompatible(final String minimalJvmVersion); static String getCurrentJavaVirtualMachineSpecificationVersion(); int compareTo(final SimpleVersion version); boolean isBackwardCompatible(final SimpleVersion version); Integer getMajor(); Integer getMedium(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
SimpleVersion implements Comparable<SimpleVersion>, Serializable { public final static SimpleVersion parse(final String version) throws IllegalArgumentException, NumberFormatException { StringTokenizer tokenizer = new StringTokenizer(version, "-"); if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException(version + " is not a valid Version"); } final String numbers = tokenizer.nextToken(); tokenizer = new StringTokenizer(numbers, "."); final Integer major = Integer.parseInt(tokenizer.nextToken()); Integer medium = null; if (tokenizer.hasMoreTokens()) { medium = Integer.parseInt(tokenizer.nextToken()); } return new SimpleVersion(major, medium); } SimpleVersion(final Integer major, final Integer medium); final static SimpleVersion parse(final String version); static boolean isCompatible(final String minimalJvmVersion); static String getCurrentJavaVirtualMachineSpecificationVersion(); int compareTo(final SimpleVersion version); boolean isBackwardCompatible(final SimpleVersion version); Integer getMajor(); Integer getMedium(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }