A representation of a generic interval. The interval can be open or closed (the start and end points may be inclusive or exclusive), as well as bounded and unbounded (it can extend to positive or negative infinity). The class doesn't assume that the intervals are numeric, instead it is generalized
| 26 | * interval. |
| 27 | */ |
| 28 | public abstract class Interval<T extends Comparable<? super T>> { |
| 29 | private T start, end; |
| 30 | private boolean isStartInclusive, isEndInclusive; |
| 31 | |
| 32 | /** |
| 33 | * An enum representing all possible types of bounded intervals. |
| 34 | */ |
| 35 | public enum Bounded { |
| 36 | /** |
| 37 | * An interval, in which both start and end point are exclusive. |
| 38 | */ |
| 39 | OPEN, |
| 40 | |
| 41 | /** |
| 42 | * An interval, in which both start and end point are inclusive. |
| 43 | */ |
| 44 | CLOSED, |
| 45 | |
| 46 | /** |
| 47 | * An interval, in which the start is exclusive and the end is inclusive. |
| 48 | */ |
| 49 | CLOSED_RIGHT, |
| 50 | |
| 51 | /** |
| 52 | * An interval, in which the start is inclusive and the end is exclusive. |
| 53 | */ |
| 54 | CLOSED_LEFT |
| 55 | } |
| 56 | |
| 57 | public enum Unbounded { |
| 58 | /** |
| 59 | * An interval extending to positive infinity and having an exclusive start |
| 60 | * point as a lower bound. For example, (5, +inf) |
| 61 | */ |
| 62 | OPEN_LEFT, |
| 63 | |
| 64 | /** |
| 65 | * An interval extending to positive infinity and having an inclusive start |
| 66 | * point as a lower bound. For example, [5, +inf) |
| 67 | */ |
| 68 | CLOSED_LEFT, |
| 69 | |
| 70 | /** |
| 71 | * An interval extending to negative infinity and having an exclusive end |
| 72 | * point as an upper bound. For example, (-inf, 5) |
| 73 | */ |
| 74 | OPEN_RIGHT, |
| 75 | |
| 76 | /** |
| 77 | * An interval extending to negative infinity and having an inclusive end |
| 78 | * point as an upper bound. For example, (-inf, 5] |
| 79 | */ |
| 80 | CLOSED_RIGHT |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Instantiates a new interval representing all points in the domain of definition, |
| 85 | * i.e. this will instantiate the interval (-inf, +inf). |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…