- Type Parameters:
N
- the type of endpointsS
- the type of spans
- All Known Implementing Classes:
ULongSpan.Domain
This defines the domain, which may introduce behaviors different than those naturally acquired from the type. For example, a domain may impose unsigned comparison on a (boxed) primitive type.
-
Method Summary
Modifier and TypeMethodDescriptionall()
Get the span containing all values in the domaindefault S
Construct a new span with the given lower endpoint, inclusive.default S
Construct a new span with the given upper endpoint, inclusive.default S
Compute the smallest span which contains two spansdefault S
Create a new span with the given endpoints, inclusive.int
Compare two valuesGet a given value, decremented by 1empty()
Get the span that contains no value, nor has any endpointsdefault boolean
Check if one span encloses anotherGet a given value, incremented by 1default S
Compute the intersection of two spansdefault boolean
intersects
(S s1, S s2) Check if two spans intersectmax()
Get the maximum value in the domaindefault N
Get the greater of two valuesmin()
Get the minimum value in the domaindefault N
Get the lesser of two valuesFactory method for a new span after arguments are validatedSubtract two spansdefault String
toMaxString
(N max) Render the upper bound of a spandefault String
toMinString
(N min) Render the lower bound of a spandefault String
Render the given value as a stringdefault String
Render the given span as a stringdefault S
Construct a span containing only the given value
-
Method Details
-
closed
Create a new span with the given endpoints, inclusive.- Parameters:
min
- the lower endpointmax
- the upper endpoint- Returns:
- the span
- Throws:
IllegalArgumentException
- if max is less than min
-
newSpan
Factory method for a new span after arguments are validated- Parameters:
min
- the lower endpointmax
- the upper endpoint- Returns:
- the span
-
value
Construct a span containing only the given value- Parameters:
n
- the value- Returns:
- the span
-
atMost
Construct a new span with the given upper endpoint, inclusive.The lower endpoint becomes the minimum value in the domain
- Parameters:
max
- the upper endpoint- Returns:
- the span
-
atLeast
Construct a new span with the given lower endpoint, inclusive.The upper endpoint becomes the maximum value in the domain
- Parameters:
min
- the lower endpoint- Returns:
- the span
-
all
S all()Get the span containing all values in the domain- Returns:
- the span
-
empty
S empty()Get the span that contains no value, nor has any endpointsThis span is returned when the result doesn't exist, e.g., when finding the intersection of spans which do not intersect.
- Returns:
- the empty span
-
toString
Render the given value as a string- Parameters:
n
- the value- Returns:
- the string
-
toString
Render the given span as a string- Parameters:
s
- the span- Returns:
- the string
-
toMinString
Render the lower bound of a span- Parameters:
min
- the lower bound- Returns:
- the string
-
toMaxString
Render the upper bound of a span- Parameters:
max
- the upper bound- Returns:
- the string
-
compare
Compare two values- Parameters:
n1
- a valuen2
- another value- Returns:
- the result, as in
Comparator.compare(Object, Object)
-
min
N min()Get the minimum value in the domainThis value can also represent negative infinity.
- Returns:
- the minimum value
-
max
N max()Get the maximum value in the domainThis value can also represent positive infinity.
- Returns:
- the maximum value
-
inc
Get a given value, incremented by 1If the resulting value would exceed
max()
, this should wrap tomin()
.- Parameters:
n
- the value- Returns:
- the value incremented
-
dec
Get a given value, decremented by 1If the resulting value would exceed
min()
, this should wrap tomax()
.- Parameters:
n
- the value- Returns:
- the value decremented
-
min
Get the lesser of two valuesIf the values are equal, then either may be chosen
- Parameters:
n1
- a valuen2
- another value- Returns:
- the lesser
-
max
Get the greater of two valuesIf the values are equal, then either may be chosen
- Parameters:
n1
- a valuen2
- another value- Returns:
- the greater
-
intersect
Compute the intersection of two spans- Parameters:
s1
- a spans2
- another span- Returns:
- the intersection, possibly empty
-
intersects
Check if two spans intersect- Parameters:
s1
- a spans2
- another span- Returns:
- true if they intersect
-
encloses
Check if one span encloses another- Parameters:
s1
- a spans2
- another span- Returns:
- true if s1 encloses s2
-
bound
Compute the smallest span which contains two spans- Parameters:
s1
- a spans2
- another span- Returns:
- the bounding span
-
subtract
Subtract two spansIf the first span is empty, this returns 0 spans.
- Parameters:
s1
- a spans2
- another span- Returns:
- 0, 1, or 2 spans
-