org.codehaus.mojo.versions.ordering
Class AbstractVersionComparator

java.lang.Object
  extended by org.codehaus.mojo.versions.ordering.AbstractVersionComparator
All Implemented Interfaces:
Comparator, VersionComparator
Direct Known Subclasses:
MavenVersionComparator, MercuryVersionComparator, NumericVersionComparator

public abstract class AbstractVersionComparator
extends Object
implements VersionComparator

Base class for version comparators.

Since:
1.0-beta-1

Constructor Summary
AbstractVersionComparator()
           
 
Method Summary
abstract  int compare(Object o1, Object o2)
          
 boolean equals(Object obj)
          Returns true if this object is the same type of comparator as the parameter.
 int getSegmentCount(org.apache.maven.artifact.versioning.ArtifactVersion v)
          Returns the number of segments specified or specifiable in the supplied artifact version.
 int hashCode()
          Returns a hash code value for the comparator class.
 org.apache.maven.artifact.versioning.ArtifactVersion incrementSegment(org.apache.maven.artifact.versioning.ArtifactVersion v, int segment)
          Increment the specified segment of the supplied version.
protected abstract  int innerGetSegmentCount(org.apache.maven.artifact.versioning.ArtifactVersion v)
           
protected abstract  org.apache.maven.artifact.versioning.ArtifactVersion innerIncrementSegment(org.apache.maven.artifact.versioning.ArtifactVersion v, int segment)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractVersionComparator

public AbstractVersionComparator()
Method Detail

compare

public abstract int compare(Object o1,
                            Object o2)

Specified by:
compare in interface Comparator

getSegmentCount

public final int getSegmentCount(org.apache.maven.artifact.versioning.ArtifactVersion v)
Returns the number of segments specified or specifiable in the supplied artifact version.

Specified by:
getSegmentCount in interface VersionComparator
Parameters:
v - The artifact version to count the segments of.
Returns:
The number of segments.

innerGetSegmentCount

protected abstract int innerGetSegmentCount(org.apache.maven.artifact.versioning.ArtifactVersion v)

incrementSegment

public final org.apache.maven.artifact.versioning.ArtifactVersion incrementSegment(org.apache.maven.artifact.versioning.ArtifactVersion v,
                                                                                   int segment)
Increment the specified segment of the supplied version.

Specified by:
incrementSegment in interface VersionComparator
Parameters:
v - The artifact version to increment.
segment - The segment number to increment.
Returns:
An artifact version with the specified segment incremented.

innerIncrementSegment

protected abstract org.apache.maven.artifact.versioning.ArtifactVersion innerIncrementSegment(org.apache.maven.artifact.versioning.ArtifactVersion v,
                                                                                              int segment)

hashCode

public int hashCode()
Returns a hash code value for the comparator class.

Overrides:
hashCode in class Object
Returns:
the hash code.

equals

public boolean equals(Object obj)
Returns true if this object is the same type of comparator as the parameter.

Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
hashCode(), Hashtable


Copyright © 2008-2011 Codehaus. All Rights Reserved.