Class TimeLineRange
java.lang.Object
overit.geocallapp.utilities.timeline.TimeLineRange
- All Implemented Interfaces:
Serializable
Represents a time range associated with a
A timeline range defines a specific time period with begin and end dates, linked to a timeline item.
Provides functionality for overlap detection, intersection calculation, and adjacency checking between ranges.
TimeLineItem for timeline operations.A timeline range defines a specific time period with begin and end dates, linked to a timeline item.
Provides functionality for overlap detection, intersection calculation, and adjacency checking between ranges.
- Since:
- 1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeLineRangebuildTimeLineRange(TimeLineItem<?> item) Creates a new TimeLineRange using the dates from the providedTimeLineItem.static TimeLineRangebuildTimeLineRange(TimeLineItem<?> item, Date begin, Date end) Creates a new TimeLineRange with custom begin and end dates for the providedTimeLineItem.booleanChecks if the specified date falls within this timeline range.getBegin()Gets the start date of this timeline range.intgetDuration(int unit) Calculates the duration of this timeline range in the specified time unit.getEnd()Gets the end date of this timeline range.TimeLineItem<?> getItem()Gets the timeline item associated with this range.getOverlappingRanges(List<TimeLineRange> ranges) Filters a list of ranges to return only those that overlap with this range.getOverlappingRanges(List<TimeLineRange> ranges, boolean considerEdges) Filters a list of ranges to return only those that overlap with this range.Date[]intersect(TimeLineRange other) Calculates the intersection between this range and another range.booleanisAdjacent(TimeLineRange range) Checks if this range is adjacent to another range.booleanisOverlapping(TimeLineRange range) Checks if the specified range overlaps with this timeline range.booleanisOverlapping(TimeLineRange range, boolean considerEdges) Checks if this timeline range overlaps with another range.toString()
-
Constructor Details
-
TimeLineRange
public TimeLineRange()
-
-
Method Details
-
buildTimeLineRange
Creates a new TimeLineRange using the dates from the providedTimeLineItem. The begin and end dates are extracted directly from the item.- Parameters:
item- theTimeLineItemto create the range from- Returns:
- a new TimeLineRange with dates from the item
- Throws:
IllegalArgumentException- if item is null
-
buildTimeLineRange
Creates a new TimeLineRange with custom begin and end dates for the providedTimeLineItem. Allows overriding the item's natural date boundaries with specific range dates.- Parameters:
item- theTimeLineItemto associate with the rangebegin- the custom begin date for the rangeend- the custom end date for the range- Returns:
- a new TimeLineRange with the specified dates
- Throws:
IllegalArgumentException- if item is null or both begin and end are null
-
getBegin
Gets the start date of this timeline range. Returns DATE_MIN if the begin date is null, representing an open-ended start.- Returns:
- the begin date of the range, or DATE_MIN if null
-
getEnd
Gets the end date of this timeline range. Returns DATE_MAX if the end date is null, representing an open-ended end.- Returns:
- the end date of the range, or DATE_MAX if null
-
getItem
Gets the timeline item associated with this range.- Returns:
- the
TimeLineItemassociated with this range
-
isOverlapping
Checks if the specified range overlaps with this timeline range. Uses edge-inclusive overlap detection by default.- Parameters:
range- theTimeLineRangeto check for overlap- Returns:
- true if the ranges overlap, false otherwise
-
isOverlapping
Checks if this timeline range overlaps with another range. Provides control over whether range edges (start and end points) are considered in overlap detection.- Parameters:
range- theTimeLineRangeto check for overlapconsiderEdges- if true, ranges touching at edges are considered overlapping; if false, edges are excluded- Returns:
- true if the ranges overlap according to the edge consideration setting, false otherwise
-
getOverlappingRanges
Filters a list of ranges to return only those that overlap with this range. Uses edge-inclusive overlap detection by default.- Parameters:
ranges- the list ofTimeLineRangeobjects to filter- Returns:
- a list containing only the ranges that overlap with this range
-
getOverlappingRanges
Filters a list of ranges to return only those that overlap with this range. Provides control over edge consideration in overlap detection.- Parameters:
ranges- the list ofTimeLineRangeobjects to filterconsiderEdges- if true, ranges touching at edges are considered overlapping; if false, edges are excluded- Returns:
- a list containing only the ranges that overlap with this range
-
intersect
Calculates the intersection between this range and another range. Returns the overlapping time period as a date array, or null if no intersection exists.- Parameters:
other- theTimeLineRangeto intersect with- Returns:
- an array containing [begin, end] dates of the intersection, or null if no intersection
-
contains
Checks if the specified date falls within this timeline range. Provides control over whether the end date boundary is included in the containment check.- Parameters:
date- the date to check for containmentexcludeEndDate- if true, the end date is excluded from containment; if false, it's included- Returns:
- true if the date is contained within the range according to the end date exclusion setting
-
isAdjacent
Checks if this range is adjacent to another range. Ranges are adjacent if one ends exactly when the other begins.- Parameters:
range- theTimeLineRangeto check for adjacency- Returns:
- true if the ranges are adjacent, false otherwise
-
getDuration
public int getDuration(int unit) Calculates the duration of this timeline range in the specified time unit.- Parameters:
unit- the time unit for duration calculation- Returns:
- the duration of the range in the specified unit
-
toString
-