VersionUtils { public static boolean isAtLeast52(@Nullable String version) { if (version == null) { return false; } int endIndex = Math.min(3, version.length()); try { return Double.parseDouble(version.substring(0, endIndex)) >= 5.2; } catch (NumberFormatException e) { return false; } } private  VersionUtils(); static boolean isAtLeast52(@Nullable String version);  }
@Test public void parse_version() { assertThat(VersionUtils.isAtLeast52("5.2")).isTrue(); assertThat(VersionUtils.isAtLeast52(null)).isFalse(); assertThat(VersionUtils.isAtLeast52("52")).isTrue(); assertThat(VersionUtils.isAtLeast52("5.0")).isFalse(); assertThat(VersionUtils.isAtLeast52("")).isFalse(); assertThat(VersionUtils.isAtLeast52("trash")).isFalse(); assertThat(VersionUtils.isAtLeast52("6.0.0")).isTrue(); assertThat(VersionUtils.isAtLeast52("5.2-SNAPSHOT")).isTrue(); assertThat(VersionUtils.isAtLeast52("6.3.0.1234")).isTrue(); }