1 package org.sonatype.aether.version; 2 3 /******************************************************************************* 4 * Copyright (c) 2010-2011 Sonatype, Inc. 5 * All rights reserved. This program and the accompanying materials 6 * are made available under the terms of the Eclipse Public License v1.0 7 * which accompanies this distribution, and is available at 8 * http://www.eclipse.org/legal/epl-v10.html 9 *******************************************************************************/ 10 11 import java.util.Collection; 12 13 /** 14 * A constraint on versions for a dependency. A constraint can either consist of one or more version ranges or a single 15 * version. In the first case, the constraint expresses a hard requirement on a version matching one of its ranges. In 16 * the second case, the constraint expresses a soft requirement on a specific version (i.e. a recommendation). 17 * 18 * @author Benjamin Bentmann 19 */ 20 public interface VersionConstraint 21 { 22 23 /** 24 * Gets the version ranges of this constraint. 25 * 26 * @return The version ranges, may be empty but never {@code null}. 27 */ 28 Collection<VersionRange> getRanges(); 29 30 /** 31 * Gets the version recommended by this constraint. 32 * 33 * @return The recommended version or {@code null} if none. 34 */ 35 Version getVersion(); 36 37 /** 38 * Determines whether the specified version satisfies this constraint. In more detail, a version satisfies this 39 * constraint if it matches at least one version range or if this constraint has no version ranges at all and the 40 * specified version equals the version recommended by the constraint. 41 * 42 * @param version The version to test, must not be {@code null}. 43 * @return {@code true} if the specified version satisfies this constraint, {@code false} otherwise. 44 */ 45 boolean containsVersion( Version version ); 46 47 }