Box

public class Box<T extends Comparable<T>> implements Comparable<T>

Abstract immutable data type that represents an interval over parameter T. In general, to define an interval over a set, we only need a total ordering relation defined over that set. For this reason, I am requiring Intervals to be defined over a type T that implements a Comparable interface (of any extension of that). The Comparable interface is slightly stricter than the previous interval definition, as it also requires some (integer) metric to assess the distance between the objects compared. However, I believe this seems coherent with the approach adopted by Moonlight, and being implemented by all numeric types, it provides a fairly general support out of the box. For the reason why Box implements Comparable itself, see compareTo.

Inheritors

Constructors

Link copied to clipboard
public void Box(T start, T end, boolean openOnLeft, boolean openOnRight)
Constructs an interval of any kind between start and end
public void Box(T start, T end)

Properties

Link copied to clipboard
public final T end
Link copied to clipboard
public final T start

Functions

Link copied to clipboard
public Box<R> apply<R extends Comparable<R>>(Function<T, R> f)
Link copied to clipboard
public int compareTo(@NotNull() @NotNull() Box<T> o)
Note that in classical interval arithmetic no total ordering relation is defined over intervals.
Link copied to clipboard
public boolean contains(T value)
Checks whether the passed value belongs to the interval
public boolean contains(Box<? extends Object> target)
Non-strict set containment between intervals
Link copied to clipboard
public boolean equals(Object obj)
Link copied to clipboard
public T getEnd()
Link copied to clipboard
public T getStart()
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public boolean isEmpty()
Link copied to clipboard
public boolean isOpenOnLeft()
Link copied to clipboard
public boolean isOpenOnRight()
Link copied to clipboard
public String toString()