1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.eclipse.aether.version; 20 21 /** 22 * A constraint on versions for a dependency. A constraint can either consist of a version range (e.g. "[1, ]") or a 23 * single version (e.g. "1.1"). In the first case, the constraint expresses a hard requirement on a version matching the 24 * range. In the second case, the constraint expresses a soft requirement on a specific version (i.e. a recommendation). 25 */ 26 public interface VersionConstraint { 27 28 /** 29 * Gets the version range of this constraint. 30 * 31 * @return The version range or {@code null} if none. 32 */ 33 VersionRange getRange(); 34 35 /** 36 * Gets the version recommended by this constraint. 37 * 38 * @return The recommended version or {@code null} if none. 39 */ 40 Version getVersion(); 41 42 /** 43 * Determines whether the specified version satisfies this constraint. In more detail, a version satisfies this 44 * constraint if it matches its version range or if this constraint has no version range and the specified version 45 * equals the version recommended by the constraint. 46 * 47 * @param version The version to test, must not be {@code null}. 48 * @return {@code true} if the specified version satisfies this constraint, {@code false} otherwise. 49 */ 50 boolean containsVersion(Version version); 51 }