KafkaVersion implements Comparable<KafkaVersion> { public static int compareDottedVersions(String version1, String version2) { String[] components = version1.split("\\."); String[] otherComponents = version2.split("\\."); for (int i = 0; i < Math.min(components.length, otherComponents.length); i++) { int x = Integer.parseInt(components[i]); int y = Integer.parseInt(otherComponents[i]); if (x == y) { continue; } else if (x < y) { return -1; } else { return 1; } } return components.length - otherComponents.length; } @JsonCreator  KafkaVersion(@JsonProperty("version") String version,
                        @JsonProperty("protocol") String protocolVersion,
                        @JsonProperty("format") String messageVersion,
                        @JsonProperty("zookeeper") String zookeeperVersion,
                        @JsonProperty("default") boolean isDefault,
                        @JsonProperty("unsupported-features") String unsupportedFeatures); static KafkaVersion parseKafkaVersions(Reader reader, Map<String, KafkaVersion> mapOfVersions); @Override String toString(); String version(); String protocolVersion(); String messageVersion(); String zookeeperVersion(); boolean isDefault(); String unsupportedFeatures(); @Override int compareTo(KafkaVersion o); int compareVersion(String version); static int compareDottedVersions(String version1, String version2); @Override int hashCode(); @Override boolean equals(Object o);  }
@Test public void compareEqualVersionTest() { assertThat(KafkaVersion.compareDottedVersions(KafkaVersionTestUtils.DEFAULT_KAFKA_VERSION, KafkaVersionTestUtils.DEFAULT_KAFKA_VERSION), is(0)); }
@Test public void compareVersionLowerTest() { assertThat(KafkaVersion.compareDottedVersions(KafkaVersionTestUtils.PREVIOUS_KAFKA_VERSION, KafkaVersionTestUtils.LATEST_KAFKA_VERSION), lessThan(0)); }
@Test public void compareVersionHigherTest() { assertThat(KafkaVersion.compareDottedVersions(KafkaVersionTestUtils.LATEST_KAFKA_VERSION, KafkaVersionTestUtils.PREVIOUS_KAFKA_VERSION), greaterThan(0)); }