com.jstatcom.model
Class NumberRangeTypes
- java.lang.Object
-
- com.jstatcom.model.NumberRangeTypes
-
public class NumberRangeTypes extends java.lang.ObjectThis 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).
-
-
Field Summary
Fields Modifier and Type Field and Description static NumberRangeTypesCLOSEDType for closed interval.static NumberRangeTypesLEFT_OPENType for left-open interval.java.lang.StringleftBracket"(" (not inclusive) or "[" (inclusive).booleanleftOpenWhether lower bound is open.static NumberRangeTypesOPENType for open interval.static NumberRangeTypesRIGHT_OPENType for right-open interval.java.lang.StringrightBracket")" (not inclusive) or "]" (inclusive).booleanrightOpenWhether upper bound is open.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static NumberRangeTypesgetTypeForBounds(boolean leftOpen, boolean rightOpen)Gets the appropriate range type according to the specification of the bounds openess.booleanisLeftOpen()Gets whether left bound is open.booleanisRightOpen()Gets whether right bound is open.java.lang.StringleftBracket()Gets the strimg for the left bracket.java.lang.Stringname()Returns the name of the type.java.lang.StringrightBracket()Gets the strimg for the right bracket.java.lang.StringtoString()Returns a string representation of the type, do not use for comparisons.
-
-
-
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 openrightOpen- whether upper bound is open- Returns:
- number range type
-
isLeftOpen
public final boolean isLeftOpen()
Gets whether left bound is open.- Returns:
trueif left bound is open
-
isRightOpen
public final boolean isRightOpen()
Gets whether right bound is open.- Returns:
trueif right bound is open
-
toString
public final java.lang.String toString()
Returns a string representation of the type, do not use for comparisons.- Overrides:
toStringin classjava.lang.Object- Returns:
- string representing this type
-
-
DMelt 3.0 © DataMelt by jWork.ORG