001package org.eclipse.aether.version; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022/** 023 * A constraint on versions for a dependency. A constraint can either consist of a version range (e.g. "[1, ]") or a 024 * single version (e.g. "1.1"). In the first case, the constraint expresses a hard requirement on a version matching the 025 * range. In the second case, the constraint expresses a soft requirement on a specific version (i.e. a recommendation). 026 */ 027public interface VersionConstraint 028{ 029 030 /** 031 * Gets the version range of this constraint. 032 * 033 * @return The version range or {@code null} if none. 034 */ 035 VersionRange getRange(); 036 037 /** 038 * Gets the version recommended by this constraint. 039 * 040 * @return The recommended version or {@code null} if none. 041 */ 042 Version getVersion(); 043 044 /** 045 * Determines whether the specified version satisfies this constraint. In more detail, a version satisfies this 046 * constraint if it matches its version range or if this constraint has no version range and the specified version 047 * equals the version recommended by the constraint. 048 * 049 * @param version The version to test, must not be {@code null}. 050 * @return {@code true} if the specified version satisfies this constraint, {@code false} otherwise. 051 */ 052 boolean containsVersion( Version version ); 053 054}