com.jstatcom.model
Class NumberRangeTypes

java.lang.Object
  extended by com.jstatcom.model.NumberRangeTypes

public class NumberRangeTypes
extends java.lang.Object

This class contains an enumeration of constants that define different types of number ranges.

It implements the typesave enum pattern (Joshua Bloch, "Effective Java", Item 21). If you compare NumberRangeTypes, always use the == operator. This is save, because they are Singletons (Gamma et al., 1995).

Author:
Markus Kraetzig

Field Summary
static NumberRangeTypes CLOSED
          Type for closed interval.
static NumberRangeTypes LEFT_OPEN
          Type for left-open interval.
 java.lang.String leftBracket
          "(" (not inclusive) or "[" (inclusive).
 boolean leftOpen
          Whether lower bound is open.
static NumberRangeTypes OPEN
          Type for open interval.
static NumberRangeTypes RIGHT_OPEN
          Type for right-open interval.
 java.lang.String rightBracket
          ")" (not inclusive) or "]" (inclusive).
 boolean rightOpen
          Whether upper bound is open.
 
Method Summary
static NumberRangeTypes getTypeForBounds(boolean leftOpen, boolean rightOpen)
          Gets the appropriate range type according to the specification of the bounds openess.
 boolean isLeftOpen()
          Gets whether left bound is open.
 boolean isRightOpen()
          Gets whether right bound is open.
 java.lang.String leftBracket()
          Gets the strimg for the left bracket.
 java.lang.String name()
          Returns the name of the type.
 java.lang.String rightBracket()
          Gets the strimg for the right bracket.
 java.lang.String toString()
          Returns a string representation of the type, do not use for comparisons.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

leftBracket

public final java.lang.String leftBracket
"(" (not inclusive) or "[" (inclusive).


rightBracket

public final java.lang.String rightBracket
")" (not inclusive) or "]" (inclusive).


leftOpen

public final boolean leftOpen
Whether lower bound is open.


rightOpen

public final boolean rightOpen
Whether upper bound is open.


CLOSED

public static final NumberRangeTypes CLOSED
Type for closed interval.


OPEN

public static final NumberRangeTypes OPEN
Type for open interval.


LEFT_OPEN

public static final NumberRangeTypes LEFT_OPEN
Type for left-open interval.


RIGHT_OPEN

public static final NumberRangeTypes RIGHT_OPEN
Type for right-open interval.

Method Detail

leftBracket

public final java.lang.String leftBracket()
Gets the strimg for the left bracket.

Returns:
"(" or "["

name

public final java.lang.String name()
Returns the name of the type. Do not use for comparisons, but compare by reference.

Returns:
name of this type

rightBracket

public final java.lang.String rightBracket()
Gets the strimg for the right bracket.

Returns:
")" or "]"

getTypeForBounds

public static final NumberRangeTypes getTypeForBounds(boolean leftOpen,
                                                      boolean rightOpen)
Gets the appropriate range type according to the specification of the bounds openess.

Parameters:
leftOpen - whether lower bound is open
rightOpen - whether upper bound is open
Returns:
number range type

isLeftOpen

public final boolean isLeftOpen()
Gets whether left bound is open.

Returns:
true if left bound is open

isRightOpen

public final boolean isRightOpen()
Gets whether right bound is open.

Returns:
true if right bound is open

toString

public final java.lang.String toString()
Returns a string representation of the type, do not use for comparisons.

Overrides:
toString in class java.lang.Object
Returns:
string representing this type