Interface Span.Domain<N, S extends Span<N,S>>
- Type Parameters:
N- the type of endpointsS- the type of spans
- All Known Implementing Classes:
End.EndDomain, FieldSpan.Domain, KeySpan.Domain, Lifespan.Domain, ULongSpan.Domain
public static interface Span.Domain<N, S extends Span<N,S>>
The (discrete) domain of endpoints for a span
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.
- Implementation Notes:
- each domain should be a singleton class
-
Method Summary
Modifier and TypeMethodDescriptionall()Get the span containing all values in the domaindefault SConstruct a new span with the given lower endpoint, inclusive.default SConstruct a new span with the given upper endpoint, inclusive.default SCompute the smallest span which contains two spansdefault SCreate a new span with the given endpoints, inclusive.intCompare two valuesGet a given value, decremented by 1empty()Get the span that contains no value, nor has any endpointsdefault booleanCheck if one span encloses anotherGet a given value, incremented by 1default SCompute the intersection of two spansdefault booleanintersects(S s1, S s2) Check if two spans intersectmax()Get the maximum value in the domaindefault NGet the greater of two valuesmin()Get the minimum value in the domaindefault NGet the lesser of two valuesFactory method for a new span after arguments are validatedSubtract two spansdefault StringtoMaxString(N max, Function<? super N, String> nToString) Render the upper bound of a spandefault StringtoMinString(N min, Function<? super N, String> nToString) Render the lower bound of a spandefault StringRender the given value as a stringdefault StringRender the given span as a stringdefault StringRender the given span as a stringdefault SConstruct 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
-
value
-
atMost
-
atLeast
-
all
S all()Get the span containing all values in the domain- Returns:
- the span
- Implementation Notes:
- It is recommended to return a static object
-
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
- Implementation Notes:
- It is recommended to implement
Span.Emptyas a singleton class and return its instance
-
toString
-
toString
-
toString
-
toMinString
-
toMaxString
-
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
-
dec
-
min
-
max
-
intersect
-
intersects
-
encloses
-
bound
-
subtract
-