Qwylt

java.lang.module
Class VersionRange

java.lang.Object
  extended by java.lang.module.VersionRange
All Implemented Interfaces:
Matcher<Version>

public class VersionRange
extends java.lang.Object
implements Matcher<Version>

A syntax agnostic Version range and Matcher

Since:
Dec 10, 2008
Author:
Bryan Atsatt

Field Summary
static VersionRange ANY
          A VersionRange instance that will match any Version.
 
Constructor Summary
VersionRange(Version minVersion, boolean includeMin, Version maxVersion, boolean includeMax)
          Constructs a VersionRange with the specified minVersion and maxVersion.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compare two Version objects for equality.
 boolean getIncludeMaximum()
          Indicates if the maximum version is included in this range.
 boolean getIncludeMinimum()
          Indicates if the minimum version is included in this range.
 Version getMaximum()
          Returns the maximum Version of this range.
 Version getMinimum()
          Returns the minimum Version of this range.
 int hashCode()
          Returns a hash code for this instance.
 boolean matches(Version version)
          Tests if the specified version is contained in this range.
 java.lang.String toString()
          Returns a String object representing this instance, in canonical form.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY

public static final VersionRange ANY
A VersionRange instance that will match any Version.

Constructor Detail

VersionRange

public VersionRange(Version minVersion,
                    boolean includeMin,
                    Version maxVersion,
                    boolean includeMax)
Constructs a VersionRange with the specified minVersion and maxVersion.

Parameters:
minVersion - The minimum version of the range.
includeMin - true if the minimum version is included in the range.
maxVersion - The maximum version of the range.
includeMax - true if the maximum version is included in the range.
Throws:
java.lang.IllegalArgumentException - if minVersion or maxVersion are null.
Method Detail

getMinimum

public Version getMinimum()
Returns the minimum Version of this range.

Returns:
the minimum Version of this range.

getIncludeMinimum

public boolean getIncludeMinimum()
Indicates if the minimum version is included in this range.

Returns:
true if the minimum version is included in this range; otherwise false is returned.

getMaximum

public Version getMaximum()
Returns the maximum Version of this range.

Returns:
the maximum Version of this range.

getIncludeMaximum

public boolean getIncludeMaximum()
Indicates if the maximum version is included in this range.

Returns:
true if the maximum version is included in this range; otherwise false is returned.

matches

public boolean matches(Version version)
Tests if the specified version is contained in this range.

Specified by:
matches in interface Matcher<Version>
Parameters:
version - The target version.
Returns:
true if the specified version is contained in this range; false otherwise.

equals

public boolean equals(java.lang.Object object)
Compare two Version objects for equality. The result is true if and only if the argument is not null and is a Version object for which compareTo() returns 0.

Overrides:
equals in class java.lang.Object
Parameters:
object - the object to compare with.
Returns:
whether or not two Version objects are equal

hashCode

public int hashCode()
Returns a hash code for this instance.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this instance.

toString

public java.lang.String toString()
Returns a String object representing this instance, in canonical form.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the value of this instance in canonical form.

Qwylt

Send comments or questions to Bryan Atsatt