net.sourceforge.stripes.util
Class Range<T extends Comparable<T>>

java.lang.Object
  extended by net.sourceforge.stripes.util.Range<T>
All Implemented Interfaces:
Comparable<Range<T>>

public class Range<T extends Comparable<T>>
extends Object
implements Comparable<Range<T>>

Utility class for working with ranges, ranging from start to end (both inclusive).

Since:
Stripes 1.6
Author:
Ward van Wanrooij

Constructor Summary
Range(T start, T end)
          Constructor for range from start to end (both inclusive).
 
Method Summary
 int compareTo(Range<T> o)
           
 boolean contains(T item)
          Checks whether an item is contained in this range.
 boolean equals(Object o)
           
 T getEnd()
          Retrieves end of the range.
 T getStart()
          Retrieves start of the range.
 int hashCode()
           
 void setEnd(T end)
          Sets end of the range.
 void setStart(T start)
          Sets start of the range.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Range

public Range(T start,
             T end)
Constructor for range from start to end (both inclusive). Start and end may not be null.

Parameters:
start - Start of the range
end - End of the range
Method Detail

getStart

public T getStart()
Retrieves start of the range.

Returns:
Start of the range

setStart

public void setStart(T start)
Sets start of the range. Start may not be null.

Parameters:
start - Start of the range

getEnd

public T getEnd()
Retrieves end of the range.

Returns:
End of the range

setEnd

public void setEnd(T end)
Sets end of the range. End may not be null.

Parameters:
end - End of the range

contains

public boolean contains(T item)
Checks whether an item is contained in this range.

Parameters:
item - Item to check
Returns:
True if item is in range

compareTo

public int compareTo(Range<T> o)
Specified by:
compareTo in interface Comparable<Range<T extends Comparable<T>>>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


© Copyright 2005-2006, Stripes Development Team.