Holger's
Java API

com.antelmann.util
Class Range<T>

java.lang.Object
  extended by com.antelmann.util.Range<T>
All Implemented Interfaces:
Serializable

public class Range<T>
extends Object
implements Serializable

provides a generic wrapper for lower- and upperbounds of an object. Both bounds are considered inclusive within the range and must not be null.

Author:
Holger Antelmann
See Also:
Serialized Form

Constructor Summary
Range(Comparable<T> lowerBound, Comparable<T> upperBound)
          both bounds are considered inclusive within the range.
Range(Comparable<T> lowerBound, Comparable<T> upperBound, boolean inclusive)
          if either or both (lower- and upperBound) are non-null, they represent a limit that is either inclusive or not depending on the given boolean.
 
Method Summary
 Comparable<T> getLowerBound()
           
 Comparable<T> getUpperBound()
           
 boolean isInclusive()
           
 boolean isInRange(T obj)
           
 boolean isInRangeUnchecked(Object obj)
          convenience method for unchecked calls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Range

public Range(Comparable<T> lowerBound,
             Comparable<T> upperBound)
both bounds are considered inclusive within the range.


Range

public Range(Comparable<T> lowerBound,
             Comparable<T> upperBound,
             boolean inclusive)
if either or both (lower- and upperBound) are non-null, they represent a limit that is either inclusive or not depending on the given boolean. Both bounds may not be null (as this doesn't make any sense).

Method Detail

getLowerBound

public Comparable<T> getLowerBound()

getUpperBound

public Comparable<T> getUpperBound()

isInclusive

public boolean isInclusive()

isInRange

public boolean isInRange(T obj)

isInRangeUnchecked

public boolean isInRangeUnchecked(Object obj)
                           throws ClassCastException
convenience method for unchecked calls

Throws:
ClassCastException


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads