1 package org.apache.maven.artifact.versioning; 2 3 18 19 25 public class Restriction 26 { 27 private final ArtifactVersion lowerBound; 28 29 private final boolean lowerBoundInclusive; 30 31 private final ArtifactVersion upperBound; 32 33 private final boolean upperBoundInclusive; 34 35 static final Restriction EVERYTHING = new Restriction( null, false, null, false ); 36 37 public Restriction( ArtifactVersion lowerBound, boolean lowerBoundInclusive, ArtifactVersion upperBound, 38 boolean upperBoundInclusive ) 39 { 40 this.lowerBound = lowerBound; 41 this.lowerBoundInclusive = lowerBoundInclusive; 42 this.upperBound = upperBound; 43 this.upperBoundInclusive = upperBoundInclusive; 44 } 45 46 public ArtifactVersion getLowerBound() 47 { 48 return lowerBound; 49 } 50 51 public boolean isLowerBoundInclusive() 52 { 53 return lowerBoundInclusive; 54 } 55 56 public ArtifactVersion getUpperBound() 57 { 58 return upperBound; 59 } 60 61 public boolean isUpperBoundInclusive() 62 { 63 return upperBoundInclusive; 64 } 65 66 public boolean containsVersion( ArtifactVersion version ) 67 { 68 if ( lowerBound != null ) 69 { 70 int comparison = lowerBound.compareTo( version ); 71 if ( comparison == 0 && !lowerBoundInclusive ) 72 { 73 return false; 74 } 75 if ( comparison > 0 ) 76 { 77 return false; 78 } 79 } 80 if ( upperBound != null ) 81 { 82 int comparison = upperBound.compareTo( version ); 83 if ( comparison == 0 && !upperBoundInclusive ) 84 { 85 return false; 86 } 87 if ( comparison < 0 ) 88 { 89 return false; 90 } 91 } 92 return true; 93 } 94 } 95 | Popular Tags |