]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.version
;
14 * A range of versions.
16 public interface VersionRange
20 * Determines whether the specified version is contained within this range.
22 * @param version The version to test, must not be {@code null}.
23 * @return {@code true} if this range contains the specified version, {@code false} otherwise.
25 boolean containsVersion( Version version
);
28 * Gets a lower bound (if any) for this range. If existent, this range does not contain any version smaller than its
29 * lower bound. Note that complex version ranges might exclude some versions even within their bounds.
31 * @return A lower bound for this range or {@code null} is there is none.
33 Bound
getLowerBound();
36 * Gets an upper bound (if any) for this range. If existent, this range does not contain any version greater than
37 * its upper bound. Note that complex version ranges might exclude some versions even within their bounds.
39 * @return An upper bound for this range or {@code null} is there is none.
41 Bound
getUpperBound();
44 * A bound of a version range.
46 static final class Bound
49 private final Version version
;
51 private final boolean inclusive
;
54 * Creates a new bound with the specified properties.
56 * @param version The bounding version, must not be {@code null}.
57 * @param inclusive A flag whether the specified version is included in the range or not.
59 public Bound( Version version
, boolean inclusive
)
61 if ( version
== null )
63 throw new IllegalArgumentException( "version missing" );
65 this.version
= version
;
66 this.inclusive
= inclusive
;
70 * Gets the bounding version.
72 * @return The bounding version, never {@code null}.
74 public Version
getVersion()
80 * Indicates whether the bounding version is included in the range or not.
82 * @return {@code true} if the bounding version is included in the range, {@code false} if not.
84 public boolean isInclusive()
90 public boolean equals( Object obj
)
96 else if ( obj
== null || !getClass().equals( obj
.getClass() ) )
101 Bound that
= (Bound
) obj
;
102 return inclusive
== that
.inclusive
&& version
.equals( that
.version
);
106 public int hashCode()
109 hash
= hash
* 31 + version
.hashCode();
110 hash
= hash
* 31 + ( inclusive ?
1 : 0 );
115 public String
toString()
117 return String
.valueOf( version
);