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 aRangeendpoint 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 intcompareByEndpoint(T lhs, T rhs)Compares the given items by the end points they hold.default intcompareByEndpoint(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.BoundTypegetBoundType(T item)EndpointDirectiongetDirection(T item)CgetPoint(T item)booleanhasBound(T item)default <R extends Comparable>
EndpointAccessor<T,R>mapping(Function<C,R> mapper)default EndpointDescriptortoDescriptor(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.UNORDEREDfor endpoints is used.- Parameters:
lhs- First item with an end point to compare.rhs- Second item with an end point to compare.- Returns:
-1if the first item is less than the second,0if both are equal, or+1otherwise.
-
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:
-1if the first item is less than the second,0if both are equal, or+1otherwise.
-
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.UNORDEREDfor 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.
-
-