コード例 #1
0
  @Override
  public String getValue() {
    if (this.value == null) {
      StringBuilder builder = new StringBuilder();

      if (getVersion() != null) {
        builder.append(getVersion());
      } else {
        if (this.ranges.size() == 1) {
          builder.append(this.ranges.get(0).getValue());
        } else {
          for (VersionRange range : getRanges()) {
            if (builder.length() > 0) {
              builder.append(RANGE_SEPARATOR);
            }
            builder.append('{');
            builder.append(range.getValue());
            builder.append('}');
          }
        }
      }

      this.value = builder.toString();
    }

    return this.value;
  }
コード例 #2
0
 /**
  * @param otherRanges the ranges to validate with this ranges
  * @throws IncompatibleVersionConstraintException the provided ranges is not compatible with this
  *     ranges
  */
 private void validateCompatibility(Collection<VersionRangeCollection> otherRanges)
     throws IncompatibleVersionConstraintException {
   for (VersionRange otherRange : otherRanges) {
     for (VersionRange range : this.ranges) {
       if (!range.isCompatible(otherRange)) {
         throw new IncompatibleVersionConstraintException(
             "Ranges [" + range + "] and [" + otherRange + "] are incompatibles");
       }
     }
   }
 }
コード例 #3
0
  @Override
  public boolean containsVersion(Version version) {
    if (this.ranges.isEmpty()) {
      return this.version != null && this.version.equals(version);
    } else {
      for (VersionRange range : this.ranges) {
        if (!range.containsVersion(version)) {
          return false;
        }
      }
    }

    return true;
  }