Package org.openl.rules.helpers
Class DoubleRange
- java.lang.Object
-
- org.openl.rules.helpers.DoubleRange
-
- All Implemented Interfaces:
INumberRange
public class DoubleRange extends Object implements INumberRange
TheDoubleRangeclass stores range of floats. Examples : "1.2-3", "2 .. 4", "123.456 ... 1000.00001" (Important: using of ".." and "..." requires spaces between numbers and separator).
-
-
Constructor Summary
Constructors Constructor Description DoubleRange()DoubleRange(double range)DoubleRange(double lowerBound, double upperBound)DoubleRange(double lowerBound, double upperBound, RangeWithBounds.BoundType lowerBoundType, RangeWithBounds.BoundType upperBoundType)DoubleRange(String range)
-
Method Summary
-
-
-
Constructor Detail
-
DoubleRange
public DoubleRange(double range)
-
DoubleRange
public DoubleRange(double lowerBound, double upperBound)
-
DoubleRange
public DoubleRange(double lowerBound, double upperBound, RangeWithBounds.BoundType lowerBoundType, RangeWithBounds.BoundType upperBoundType)
-
DoubleRange
public DoubleRange()
-
DoubleRange
public DoubleRange(String range)
-
-
Method Detail
-
isTruncated
protected static boolean isTruncated(Number from, double to)
Returns true if converted value is truncated- Parameters:
from- converting numberto- converted double value- Returns:
- true if converted value is truncated
-
compareLowerBound
public int compareLowerBound(DoubleRange range)
Compares lower bounds.- Parameters:
range- the DoubleRange to be compared- Returns:
- a negative integer, zero, or a positive integer as lower bound of this range is less than, equal to, or greater than the lower bound of specified range.
-
compareUpperBound
public int compareUpperBound(DoubleRange range)
Compares upper bounds.- Parameters:
range- the DoubleRange to be compared- Returns:
- a negative integer, zero, or a positive integer as upper bound of this range is less than, equal to, or greater than the upper bound of specified range.
-
contains
public boolean contains(double x)
-
contains
public boolean contains(DoubleRange range)
-
contains
public boolean contains(Number n)
- Specified by:
containsin interfaceINumberRange
-
getLowerBound
public double getLowerBound()
- Returns:
- Returns the lowerBound.
-
getUpperBound
public double getUpperBound()
- Returns:
- Returns the upperBound.
-
intersect
public DoubleRange intersect(DoubleRange range)
-
setLowerBound
public void setLowerBound(double lowerBound)
- Parameters:
lowerBound- The lowerBound to set.
-
setUpperBound
public void setUpperBound(double upperBound)
- Parameters:
upperBound- The upperBound to set.
-
getLowerBoundType
public RangeWithBounds.BoundType getLowerBoundType()
-
setLowerBoundType
public void setLowerBoundType(RangeWithBounds.BoundType lowerBoundType)
-
getUpperBoundType
public RangeWithBounds.BoundType getUpperBoundType()
-
setUpperBoundType
public void setUpperBoundType(RangeWithBounds.BoundType upperBoundType)
-
autocast
public static DoubleRange autocast(byte x, DoubleRange y)
-
distance
public static int distance(byte x, DoubleRange y)
-
autocast
public static DoubleRange autocast(short x, DoubleRange y)
-
distance
public static int distance(short x, DoubleRange y)
-
autocast
public static DoubleRange autocast(int x, DoubleRange y)
-
distance
public static int distance(int x, DoubleRange y)
-
autocast
public static DoubleRange autocast(long x, DoubleRange y)
-
distance
public static int distance(long x, DoubleRange y)
-
autocast
public static DoubleRange autocast(float x, DoubleRange y)
-
distance
public static int distance(float x, DoubleRange y)
-
autocast
public static DoubleRange autocast(double x, DoubleRange y)
-
distance
public static int distance(double x, DoubleRange y)
-
cast
public static DoubleRange cast(BigInteger x, DoubleRange y)
-
distance
public static int distance(BigInteger x, DoubleRange y)
-
cast
public static DoubleRange cast(BigDecimal x, DoubleRange y)
-
distance
public static int distance(BigDecimal x, DoubleRange y)
-
autocast
public static DoubleRange autocast(IntRange x, DoubleRange y)
-
-