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