@Test public void testGetMostSpecificMatchingField() { Version v1 = VersionUtils.parseVersion("4.0.5"); Version v2 = VersionUtils.parseVersion("4.0.5"); assertEquals(Version.Field.LOCAL, VersionUtils.getMostSpecificMatchingField(v1, v2)); assertEquals(Version.Field.LOCAL, VersionUtils.getMostSpecificMatchingField(v2, v1)); v2 = VersionUtils.parseVersion("4.0.5.1"); assertEquals(Version.Field.PATCH, VersionUtils.getMostSpecificMatchingField(v1, v2)); assertEquals(Version.Field.PATCH, VersionUtils.getMostSpecificMatchingField(v2, v1)); v1 = VersionUtils.parseVersion("4.0.5.2"); v2 = VersionUtils.parseVersion("4.0.5.3"); assertEquals(Version.Field.PATCH, VersionUtils.getMostSpecificMatchingField(v1, v2)); assertEquals(Version.Field.PATCH, VersionUtils.getMostSpecificMatchingField(v2, v1)); v2 = VersionUtils.parseVersion("4.0.6"); assertEquals(Version.Field.MINOR, VersionUtils.getMostSpecificMatchingField(v1, v2)); assertEquals(Version.Field.MINOR, VersionUtils.getMostSpecificMatchingField(v2, v1)); v2 = VersionUtils.parseVersion("4.1.0.0"); assertEquals(Version.Field.MAJOR, VersionUtils.getMostSpecificMatchingField(v1, v2)); assertEquals(Version.Field.MAJOR, VersionUtils.getMostSpecificMatchingField(v2, v1)); v2 = VersionUtils.parseVersion("5.6.7"); assertNull(VersionUtils.getMostSpecificMatchingField(v1, v2)); assertNull(VersionUtils.getMostSpecificMatchingField(v2, v1)); }
public static Version.Field getMostSpecificMatchingField(Version v1, Version v2) { if (v1.getMajor() != v2.getMajor()) { return null; } if (v1.getMinor() != v2.getMinor()) { return Version.Field.MAJOR; } if (v1.getPatch() != v2.getPatch()) { return Version.Field.MINOR; } final Integer l1 = v1.getLocal(); final Integer l2 = v2.getLocal(); if (l1 != l2 && (l1 == null || l2 == null || !l1.equals(l2))) { return Version.Field.PATCH; } return Version.Field.LOCAL; }
VersionUtils { public static Version.Field getMostSpecificMatchingField(Version v1, Version v2) { if (v1.getMajor() != v2.getMajor()) { return null; } if (v1.getMinor() != v2.getMinor()) { return Version.Field.MAJOR; } if (v1.getPatch() != v2.getPatch()) { return Version.Field.MINOR; } final Integer l1 = v1.getLocal(); final Integer l2 = v2.getLocal(); if (l1 != l2 && (l1 == null || l2 == null || !l1.equals(l2))) { return Version.Field.PATCH; } return Version.Field.LOCAL; } }
VersionUtils { public static Version.Field getMostSpecificMatchingField(Version v1, Version v2) { if (v1.getMajor() != v2.getMajor()) { return null; } if (v1.getMinor() != v2.getMinor()) { return Version.Field.MAJOR; } if (v1.getPatch() != v2.getPatch()) { return Version.Field.MINOR; } final Integer l1 = v1.getLocal(); final Integer l2 = v2.getLocal(); if (l1 != l2 && (l1 == null || l2 == null || !l1.equals(l2))) { return Version.Field.PATCH; } return Version.Field.LOCAL; }  }
VersionUtils { public static Version.Field getMostSpecificMatchingField(Version v1, Version v2) { if (v1.getMajor() != v2.getMajor()) { return null; } if (v1.getMinor() != v2.getMinor()) { return Version.Field.MAJOR; } if (v1.getPatch() != v2.getPatch()) { return Version.Field.MINOR; } final Integer l1 = v1.getLocal(); final Integer l2 = v2.getLocal(); if (l1 != l2 && (l1 == null || l2 == null || !l1.equals(l2))) { return Version.Field.PATCH; } return Version.Field.LOCAL; }  static Version parseVersion(String versionString); static Version.Field getMostSpecificMatchingField(Version v1, Version v2); static boolean canUpdate(Version from, Version to); }
VersionUtils { public static Version.Field getMostSpecificMatchingField(Version v1, Version v2) { if (v1.getMajor() != v2.getMajor()) { return null; } if (v1.getMinor() != v2.getMinor()) { return Version.Field.MAJOR; } if (v1.getPatch() != v2.getPatch()) { return Version.Field.MINOR; } final Integer l1 = v1.getLocal(); final Integer l2 = v2.getLocal(); if (l1 != l2 && (l1 == null || l2 == null || !l1.equals(l2))) { return Version.Field.PATCH; } return Version.Field.LOCAL; }  static Version parseVersion(String versionString); static Version.Field getMostSpecificMatchingField(Version v1, Version v2); static boolean canUpdate(Version from, Version to);  }