public int getNature() { if ( artifact.getVersion() != null ) { return artifact.isSnapshot() ? SNAPSHOT : RELEASE; } VersionRange range = artifact.getVersionRange(); if ( range != null ) { for ( Restriction restriction : range.getRestrictions() ) { if ( isSnapshot( restriction.getLowerBound() ) || isSnapshot( restriction.getUpperBound() ) ) { return RELEASE_OR_SNAPSHOT; } } } return RELEASE; }
for ( Restriction r : ( (List<Restriction>) range.getRestrictions() ) )
for ( Restriction r : ( (List<Restriction>) range.getRestrictions() ) )
/** * Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently the default * containsVersion method assumes a singular version means allow everything. This method assumes that "2.0.4" == * "[2.0.4,)" * * @param allowedRange range of allowed versions. * @param theVersion the version to be checked. * @return true if the version is contained by the range. */ public static boolean containsVersion( VersionRange allowedRange, ArtifactVersion theVersion ) { ArtifactVersion recommendedVersion = allowedRange.getRecommendedVersion(); if ( recommendedVersion == null ) { List<Restriction> restrictions = allowedRange.getRestrictions(); for ( Restriction restriction : restrictions ) { if ( restriction.containsVersion( theVersion ) ) { return true; } } } // only singular versions ever have a recommendedVersion return recommendedVersion.compareTo( theVersion ) <= 0; } }
List<Restriction> restrictions = allowedRange.getRestrictions(); for ( Restriction restriction : restrictions )
if ( recommendedVersion == null ) List<Restriction> restrictions = allowedRange.getRestrictions(); for ( Restriction restriction : restrictions )
if ( recommendedVersion == null ) List<Restriction> restrictions = vr.getRestrictions(); for ( Restriction restriction : restrictions )