@Test public void pythonVersionIsNotRecognized() throws Exception { assertThatIllegalStateException().isThrownBy(() -> PythonVersion.from("invalid")) .withMessage("Unable to recognize Python version number") .withNoCause(); }
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();  }