Package de.xima.fc.utils.range
Class Endpoint<C extends Comparable>
- java.lang.Object
 - 
- de.xima.fc.utils.range.Endpoint<C>
 
 
- 
- Type Parameters:
 C- Type of the items of the ranges.
- All Implemented Interfaces:
 EndpointAccessor<Void,C>,EndpointDescriptor,EndpointType,Serializable,Comparable<Endpoint<C>>
public class Endpoint<C extends Comparable> extends Object implements EndpointDescriptor, EndpointAccessor<Void,C>, Comparable<Endpoint<C>>, Serializable
POJO class describing an end point of a range, either a lower or upper end point. Contains the point and its meta data.- Since:
 - 6.5.0
 - Author:
 - XIMA MEDIA GmbH
 - See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected com.google.common.collect.BoundTypeboundTypestatic Comparator<Endpoint<Comparable>>CANONICAL_COMPARATORCanonical comparator for two end points.protected EndpointDirectiondirectionstatic Endpoint<?>NEGATIVE_INFINITYImmutable singleton instance of the end point representing negative infinity.protected Cpointstatic Endpoint<?>POSITIVE_INFINITYImmutable singleton instance of the end point representing positive infinity. 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedEndpoint(C point, com.google.common.collect.BoundType boundType, EndpointDirection direction)protectedEndpoint(T item, EndpointAccessor<T,C> endpoint) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <C extends Comparable>
Endpoint<C>closed(C point, EndpointDirection direction)static <C extends Comparable>
intcompare(Endpoint<C> lhs, Endpoint<C> rhs)intcompareTo(Endpoint<C> rhs)static <C extends Comparable>
Comparator<Endpoint<C>>createComparator()static <C extends Comparable>
Comparator<Endpoint<C>>createComparator(EndpointTypeComparator comparator)booleanequals(Object obj)static <C extends Comparable>
Endpoint<C>finite(C point, com.google.common.collect.BoundType boundType, EndpointDirection direction)com.google.common.collect.BoundTypegetBoundType()com.google.common.collect.BoundTypegetBoundType(Void item)EndpointDirectiongetDirection()EndpointDirectiongetDirection(Void item)CgetPoint()CgetPoint(Void item)booleanhasBound()booleanhasBound(Void item)inthashCode()static <C extends Comparable>
Endpoint<C>infinite(EndpointDirection direction)static <C extends Comparable>
Endpoint<C>lower(C point, com.google.common.collect.BoundType boundType)static <C extends Comparable>
Endpoint<C>lowerClosed(C point)static <C extends Comparable>
Endpoint<C>lowerOpen(C point)static <C extends Comparable>
Endpoint<C>negativeInfinity()static <C extends Comparable>
Endpoint<C>of(C point, EndpointDescriptor descriptor)static <T,C extends Comparable>
Endpoint<C>of(T item, EndpointAccessor<T,C> accessor)static <C extends Comparable>
Endpoint<C>open(C point, EndpointDirection direction)static <C extends Comparable>
Endpoint<C>positiveInfinity()StringtoString()static <C extends Comparable>
Endpoint<C>upper(C point, com.google.common.collect.BoundType boundType)static <C extends Comparable>
Endpoint<C>upperClosed(C point)static <C extends Comparable>
Endpoint<C>upperOpen(C point)- 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface de.xima.fc.utils.range.EndpointAccessor
compareByEndpoint, compareByEndpoint, createByEndpointComparator, createByEndpointComparator, mapping, toDescriptor, toEndpoint 
- 
Methods inherited from interface de.xima.fc.utils.range.EndpointDescriptor
isLowerPoint, isUpperPoint, toAcessor, toEndpoint 
 - 
 
 - 
 
- 
- 
Field Detail
- 
CANONICAL_COMPARATOR
public static final Comparator<Endpoint<Comparable>> CANONICAL_COMPARATOR
Canonical comparator for two end points. 
- 
NEGATIVE_INFINITY
public static final Endpoint<?> NEGATIVE_INFINITY
Immutable singleton instance of the end point representing negative infinity. 
- 
POSITIVE_INFINITY
public static final Endpoint<?> POSITIVE_INFINITY
Immutable singleton instance of the end point representing positive infinity. 
- 
boundType
protected final com.google.common.collect.BoundType boundType
 
- 
direction
protected final EndpointDirection direction
 
- 
point
protected final C extends Comparable point
 
 - 
 
- 
Constructor Detail
- 
Endpoint
protected Endpoint(C point, com.google.common.collect.BoundType boundType, EndpointDirection direction)
 
- 
Endpoint
protected Endpoint(T item, EndpointAccessor<T,C> endpoint) 
 - 
 
- 
Method Detail
- 
compareTo
public int compareTo(Endpoint<C> rhs)
- Specified by:
 compareToin interfaceComparable<C extends Comparable>
 
- 
getBoundType
public com.google.common.collect.BoundType getBoundType()
- Specified by:
 getBoundTypein interfaceEndpointDescriptor- Specified by:
 getBoundTypein interfaceEndpointType- Returns:
 - Whether the interval end is open or closed.
 
 
- 
getBoundType
public com.google.common.collect.BoundType getBoundType(Void item)
- Specified by:
 getBoundTypein interfaceEndpointAccessor<Void,C extends Comparable>- Parameters:
 item- An item with an endpoint to check.- Returns:
 - Whether the endpoint describes by the given item is closed or open.
 
 
- 
getDirection
public EndpointDirection getDirection()
- Specified by:
 getDirectionin interfaceEndpointDescriptor- Specified by:
 getDirectionin interfaceEndpointType- Returns:
 - Whether the interval end is a lower or upper end.
 
 
- 
getDirection
public EndpointDirection getDirection(Void item)
- Specified by:
 getDirectionin interfaceEndpointAccessor<Void,C extends Comparable>- 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
public C getPoint()
- Returns:
 - The point object hold by this end point.
 - Throws:
 IllegalStateException- WhenhasBound()returnsfalse.
 
- 
getPoint
public C getPoint(Void item)
- Specified by:
 getPointin interfaceEndpointAccessor<Void,C extends Comparable>- Parameters:
 item- An item with an endpoint to process.- Returns:
 - The endpoint described by the given item.
 
 
- 
hasBound
public boolean hasBound()
- Specified by:
 hasBoundin interfaceEndpointDescriptor- Returns:
 - Whether this end point has a bound with an associated point object, or is unbounded (negative or positive infinity).
 
 
- 
hasBound
public boolean hasBound(Void item)
- Specified by:
 hasBoundin interfaceEndpointAccessor<Void,C extends Comparable>- 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).
 
 
- 
closed
public static <C extends Comparable> Endpoint<C> closed(C point, EndpointDirection direction)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.direction- Whether to create a lower or upper end point.- Returns:
 - A closed end point for the given parameters.
 
 
- 
compare
public static <C extends Comparable> int compare(Endpoint<C> lhs, Endpoint<C> rhs)
Compares first bygetPoint(), ifhasBound(), then by theEndpointType. Uses theEndpointTypeComparators.UNORDEREDfor comparing end point types.- Type Parameters:
 C- Type of the end point object.- Parameters:
 lhs- First end point to compare.rhs- Second end point to compare.- Returns:
 - Result of the comparison.
 
 
- 
createComparator
public static <C extends Comparable> Comparator<Endpoint<C>> createComparator()
- Type Parameters:
 C- Type of the end point object.- Returns:
 - A comparator for end points. Compares first by 
getPoint(), ifhasBound(), then by theEndpointType. Uses theEndpointTypeComparators.CANONICALfor comparing end point types. 
 
- 
createComparator
public static <C extends Comparable> Comparator<Endpoint<C>> createComparator(EndpointTypeComparator comparator)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 comparator- Comparator for comparing end point types.- Returns:
 - A comparator for end points. Compares first by 
getPoint(), ifhasBound(), then by the given end point comparator. 
 
- 
finite
public static <C extends Comparable> Endpoint<C> finite(C point, com.google.common.collect.BoundType boundType, EndpointDirection direction)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.boundType- Whether to create an open or closed end point.direction- Whether to create a lower or upper end point.- Returns:
 - A finite end point for the given parameters.
 
 
- 
infinite
public static <C extends Comparable> Endpoint<C> infinite(EndpointDirection direction)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 direction- Whether to create a lower or upper end point.- Returns:
 - A infinite end point with the given parameters.
 
 
- 
lower
public static <C extends Comparable> Endpoint<C> lower(C point, com.google.common.collect.BoundType boundType)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.boundType- Whether to create an open or closed end point.- Returns:
 - A lower end point for the given parameters.
 
 
- 
lowerClosed
public static <C extends Comparable> Endpoint<C> lowerClosed(C point)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.- Returns:
 - A lower closed end point for the given parameters.
 
 
- 
lowerOpen
public static <C extends Comparable> Endpoint<C> lowerOpen(C point)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.- Returns:
 - A lower open end point for the given parameters.
 
 
- 
negativeInfinity
public static <C extends Comparable> Endpoint<C> negativeInfinity()
- Type Parameters:
 C- Type of the end point object.- Returns:
 - An end point describing positive infinity.
 
 
- 
of
public static <C extends Comparable> Endpoint<C> of(C point, EndpointDescriptor descriptor)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.descriptor- Meta data about the end point to create-- Returns:
 - An end point for the given parameters.
 
 
- 
of
public static <T,C extends Comparable> Endpoint<C> of(T item, EndpointAccessor<T,C> accessor)
- Type Parameters:
 T- Type of the objects holding an end point.C- Type of the end point object.- Parameters:
 item- Object that holds an end point.accessor- Accessor for accessing the end point on the given object.- Returns:
 - An end point for the given parameters.
 
 
- 
open
public static <C extends Comparable> Endpoint<C> open(C point, EndpointDirection direction)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.direction- Whether to create a lower or upper end point.- Returns:
 - An open end point for the given parameters.
 
 
- 
positiveInfinity
public static <C extends Comparable> Endpoint<C> positiveInfinity()
- Type Parameters:
 C- Type of the end point object.- Returns:
 - An end point describing positive infinity.
 
 
- 
upper
public static <C extends Comparable> Endpoint<C> upper(C point, com.google.common.collect.BoundType boundType)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.boundType- Whether to create an open or closed end poit.- Returns:
 - An upper end point for the given parameters.
 
 
- 
upperClosed
public static <C extends Comparable> Endpoint<C> upperClosed(C point)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.- Returns:
 - An upper closed end point for the given parameters.
 
 
- 
upperOpen
public static <C extends Comparable> Endpoint<C> upperOpen(C point)
- Type Parameters:
 C- Type of the end point object.- Parameters:
 point- End point object.- Returns:
 - An upper open end point for the given parameters.
 
 
 - 
 
 -