@Test public void testMinorVersionSupported2() throws Exception { VersionMatcher versionMatcher = new VersionMatcher(); Assert.assertFalse(versionMatcher.versionSupported("1*", "2")); }
public boolean versionSupported(final String requiredVersion, final String publishedVersion) { if (requiredVersion == null) { throw new IllegalArgumentException("requiredVersion is null"); } if (publishedVersion == null) { throw new IllegalArgumentException("publishedVersion is null"); } boolean supported; Version versionRequired = new Version(requiredVersion); Version versionBeingTested = new Version(publishedVersion); if (versionRequired.minorVersionSupport() || versionRequired.majorVersionSupport()) { boolean minorVersionSupport = versionRequired.minorVersionSupport(); int[] required; int[] configured; boolean isRange = versionBeingTested.isRange(); try { required = toIntArray(versionRequired.getVersion().split("\\D")); configured = toIntArray(versionBeingTested.getVersion().split("\\D")); } catch(NumberFormatException e) { return false; } if (required.length == 0) return true; if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } if (!supported && isRange) { try { configured = toIntArray(versionBeingTested.getEndRange().split("\\D")); } catch(NumberFormatException e) { return false; } if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } } } else { if (versionBeingTested.isRange()) { supported = withinRange(versionBeingTested, versionRequired); } else { supported = versionBeingTested.equals(versionRequired); } } return supported; }
VersionMatcher implements Serializable { public boolean versionSupported(final String requiredVersion, final String publishedVersion) { if (requiredVersion == null) { throw new IllegalArgumentException("requiredVersion is null"); } if (publishedVersion == null) { throw new IllegalArgumentException("publishedVersion is null"); } boolean supported; Version versionRequired = new Version(requiredVersion); Version versionBeingTested = new Version(publishedVersion); if (versionRequired.minorVersionSupport() || versionRequired.majorVersionSupport()) { boolean minorVersionSupport = versionRequired.minorVersionSupport(); int[] required; int[] configured; boolean isRange = versionBeingTested.isRange(); try { required = toIntArray(versionRequired.getVersion().split("\\D")); configured = toIntArray(versionBeingTested.getVersion().split("\\D")); } catch(NumberFormatException e) { return false; } if (required.length == 0) return true; if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } if (!supported && isRange) { try { configured = toIntArray(versionBeingTested.getEndRange().split("\\D")); } catch(NumberFormatException e) { return false; } if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } } } else { if (versionBeingTested.isRange()) { supported = withinRange(versionBeingTested, versionRequired); } else { supported = versionBeingTested.equals(versionRequired); } } return supported; } }
VersionMatcher implements Serializable { public boolean versionSupported(final String requiredVersion, final String publishedVersion) { if (requiredVersion == null) { throw new IllegalArgumentException("requiredVersion is null"); } if (publishedVersion == null) { throw new IllegalArgumentException("publishedVersion is null"); } boolean supported; Version versionRequired = new Version(requiredVersion); Version versionBeingTested = new Version(publishedVersion); if (versionRequired.minorVersionSupport() || versionRequired.majorVersionSupport()) { boolean minorVersionSupport = versionRequired.minorVersionSupport(); int[] required; int[] configured; boolean isRange = versionBeingTested.isRange(); try { required = toIntArray(versionRequired.getVersion().split("\\D")); configured = toIntArray(versionBeingTested.getVersion().split("\\D")); } catch(NumberFormatException e) { return false; } if (required.length == 0) return true; if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } if (!supported && isRange) { try { configured = toIntArray(versionBeingTested.getEndRange().split("\\D")); } catch(NumberFormatException e) { return false; } if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } } } else { if (versionBeingTested.isRange()) { supported = withinRange(versionBeingTested, versionRequired); } else { supported = versionBeingTested.equals(versionRequired); } } return supported; }  }
VersionMatcher implements Serializable { public boolean versionSupported(final String requiredVersion, final String publishedVersion) { if (requiredVersion == null) { throw new IllegalArgumentException("requiredVersion is null"); } if (publishedVersion == null) { throw new IllegalArgumentException("publishedVersion is null"); } boolean supported; Version versionRequired = new Version(requiredVersion); Version versionBeingTested = new Version(publishedVersion); if (versionRequired.minorVersionSupport() || versionRequired.majorVersionSupport()) { boolean minorVersionSupport = versionRequired.minorVersionSupport(); int[] required; int[] configured; boolean isRange = versionBeingTested.isRange(); try { required = toIntArray(versionRequired.getVersion().split("\\D")); configured = toIntArray(versionBeingTested.getVersion().split("\\D")); } catch(NumberFormatException e) { return false; } if (required.length == 0) return true; if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } if (!supported && isRange) { try { configured = toIntArray(versionBeingTested.getEndRange().split("\\D")); } catch(NumberFormatException e) { return false; } if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } } } else { if (versionBeingTested.isRange()) { supported = withinRange(versionBeingTested, versionRequired); } else { supported = versionBeingTested.equals(versionRequired); } } return supported; }  boolean versionSupported(final String requiredVersion, final String publishedVersion); }
VersionMatcher implements Serializable { public boolean versionSupported(final String requiredVersion, final String publishedVersion) { if (requiredVersion == null) { throw new IllegalArgumentException("requiredVersion is null"); } if (publishedVersion == null) { throw new IllegalArgumentException("publishedVersion is null"); } boolean supported; Version versionRequired = new Version(requiredVersion); Version versionBeingTested = new Version(publishedVersion); if (versionRequired.minorVersionSupport() || versionRequired.majorVersionSupport()) { boolean minorVersionSupport = versionRequired.minorVersionSupport(); int[] required; int[] configured; boolean isRange = versionBeingTested.isRange(); try { required = toIntArray(versionRequired.getVersion().split("\\D")); configured = toIntArray(versionBeingTested.getVersion().split("\\D")); } catch(NumberFormatException e) { return false; } if (required.length == 0) return true; if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } if (!supported && isRange) { try { configured = toIntArray(versionBeingTested.getEndRange().split("\\D")); } catch(NumberFormatException e) { return false; } if (minorVersionSupport) { supported = checkMinorVersion(required, configured); } else { supported = checkMajorVersion(required, configured); } } } else { if (versionBeingTested.isRange()) { supported = withinRange(versionBeingTested, versionRequired); } else { supported = versionBeingTested.equals(versionRequired); } } return supported; }  boolean versionSupported(final String requiredVersion, final String publishedVersion);  }