@Test public void pythonVersionIsRecognized() throws Exception { SoftAssertions.assertSoftly(softly -> { softly.assertThat(PythonVersion.from("Robot Framework 3.0.1 (Python 2.7.14 on win32)")) .isEqualTo(new PythonVersion(2, 7, 14)); softly.assertThat(PythonVersion.from("Robot Framework 3.0.2 (Python 3.6.5 on win32)")) .isEqualTo(new PythonVersion(3, 6, 5)); softly.assertThat(PythonVersion.from("Robot Framework 3.0.3 (Jython 2.7.0 on java1.8.0_144)")) .isEqualTo(new PythonVersion(2, 7, 0)); softly.assertThat(PythonVersion.from("Robot Framework 3.0.4 (Python 2.6.6 on win32)")) .isEqualTo(new PythonVersion(2, 6, 6)); softly.assertThat(PythonVersion.from("Robot Framework 3.0.5 (Python 2.7.13+ on linux)")) .isEqualTo(new PythonVersion(2, 7, 13)); softly.assertThat(PythonVersion.from("Robot Framework 3.0.6 (Python 2.6.8a3 on linux)")) .isEqualTo(new PythonVersion(2, 6, 8)); }); }
public static PythonVersion from(final String version) { final Matcher matcher = Pattern.compile("\\(.+(\\d)\\.(\\d+)\\.(\\d+).* on .+\\)").matcher(version); if (matcher.find()) { return new PythonVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3))); } throw new IllegalStateException("Unable to recognize Python version number"); }
PythonVersion { public static PythonVersion from(final String version) { final Matcher matcher = Pattern.compile("\\(.+(\\d)\\.(\\d+)\\.(\\d+).* on .+\\)").matcher(version); if (matcher.find()) { return new PythonVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3))); } throw new IllegalStateException("Unable to recognize Python version number"); } }
PythonVersion { public static PythonVersion from(final String version) { final Matcher matcher = Pattern.compile("\\(.+(\\d)\\.(\\d+)\\.(\\d+).* on .+\\)").matcher(version); if (matcher.find()) { return new PythonVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3))); } throw new IllegalStateException("Unable to recognize Python version number"); } PythonVersion(final int major, final int minor, final int micro); }
PythonVersion { public static PythonVersion from(final String version) { final Matcher matcher = Pattern.compile("\\(.+(\\d)\\.(\\d+)\\.(\\d+).* on .+\\)").matcher(version); if (matcher.find()) { return new PythonVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3))); } throw new IllegalStateException("Unable to recognize Python version number"); } PythonVersion(final int major, final int minor, final int micro); static PythonVersion from(final String version); boolean isDeprecated(); String asString(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); }
PythonVersion { public static PythonVersion from(final String version) { final Matcher matcher = Pattern.compile("\\(.+(\\d)\\.(\\d+)\\.(\\d+).* on .+\\)").matcher(version); if (matcher.find()) { return new PythonVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3))); } throw new IllegalStateException("Unable to recognize Python version number"); } PythonVersion(final int major, final int minor, final int micro); static PythonVersion from(final String version); boolean isDeprecated(); String asString(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }