Package de.xima.fc.utils.range
Interface EndpointAccessor<T,C extends Comparable>
-
- Type Parameters:
T
- Type of the object that contains or holds an endpoint.C
- Type of the endpoint of the range, i.e.Range.lowerEndpoint()
orRange.upperEndpoint()
.
- All Known Implementing Classes:
Endpoint
,EndpointAccessorsIdentity
,EndpointAccessorsRange
public interface EndpointAccessor<T,C extends Comparable>
Interface for a handler that allows accessing aRange
endpoint of some object.- Since:
- 6.5.0
- Author:
- XIMA MEDIA GmbH
- See Also:
EndpointAccessorsIdentity
,EndpointAccessorsRange
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default int
compareByEndpoint(T lhs, T rhs)
Compares the given items by the end points they hold.default int
compareByEndpoint(T lhs, T rhs, EndpointTypeComparator comparator)
Compares the given items by the end points they hold.default Comparator<T>
createByEndpointComparator()
default Comparator<T>
createByEndpointComparator(EndpointTypeComparator comparator)
com.google.common.collect.BoundType
getBoundType(T item)
EndpointDirection
getDirection(T item)
C
getPoint(T item)
boolean
hasBound(T item)
default <R extends Comparable>
EndpointAccessor<T,R>mapping(Function<C,R> mapper)
default EndpointDescriptor
toDescriptor(T item)
Creates an endpoint descriptor describing the endpoint of held by the given item.default Endpoint<C>
toEndpoint(T item)
-
-
-
Method Detail
-
compareByEndpoint
default int compareByEndpoint(T lhs, T rhs)
Compares the given items by the end points they hold. The default comparatorEndpointTypeComparators.UNORDERED
for endpoints is used.- Parameters:
lhs
- First item with an end point to compare.rhs
- Second item with an end point to compare.- Returns:
-1
if the first item is less than the second,0
if both are equal, or+1
otherwise.
-
compareByEndpoint
default int compareByEndpoint(T lhs, T rhs, EndpointTypeComparator comparator)
Compares the given items by the end points they hold.- Parameters:
lhs
- First item with an end point to compare.rhs
- Second item with an end point to compare.comparator
- The comparator to use for comparing the end points.- Returns:
-1
if the first item is less than the second,0
if both are equal, or+1
otherwise.
-
createByEndpointComparator
default Comparator<T> createByEndpointComparator()
- Returns:
- A comparator for the items holding an endpoint, that compares the items the endpoint they hold. The
default comparator
EndpointTypeComparators.UNORDERED
for endpoints is used.
-
createByEndpointComparator
default Comparator<T> createByEndpointComparator(EndpointTypeComparator comparator)
- Parameters:
comparator
- Comparator to use for comparing the endpoints.- Returns:
- A comparator for the items holding an endpoint, that compares the items the endpoint they hold.
-
getBoundType
com.google.common.collect.BoundType getBoundType(T item)
- Parameters:
item
- An item with an endpoint to check.- Returns:
- Whether the endpoint describes by the given item is closed or open.
-
getDirection
EndpointDirection getDirection(T item)
- Parameters:
item
- An item with an endpoint to check.- Returns:
- Whether the end point described by the given item is a lower or upper end point.
-
getPoint
C getPoint(T item)
- Parameters:
item
- An item with an endpoint to process.- Returns:
- The endpoint described by the given item.
-
hasBound
boolean hasBound(T item)
- Parameters:
item
- An item with an endpoint to check.- Returns:
- Whether the range defined by the item has a bound (or describes positive or negative infinity).
-
mapping
default <R extends Comparable> EndpointAccessor<T,R> mapping(Function<C,R> mapper)
- Type Parameters:
R
- Type of the mapped point.- Parameters:
mapper
- Mapping function that converts thegetPoint(Object)
to another object.- Returns:
- A new endpoint accessor with the same
getBoundType(Object)
andgetDirection(Object)
, but with thegetPoint(Object)
mapped via the given mapping function.
-
toDescriptor
default EndpointDescriptor toDescriptor(T item)
Creates an endpoint descriptor describing the endpoint of held by the given item.- Parameters:
item
- An item holding an endpoint.- Returns:
- An endpoint descriptor for the endpoint of the given item.
-
-