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