Class AbstractInTimeRange<T extends Comparable<T>>
- java.lang.Object
-
- uk.gov.gchq.koryphe.predicate.KoryphePredicate<T>
-
- uk.gov.gchq.koryphe.impl.predicate.range.AbstractInTimeRange<T>
-
- All Implemented Interfaces:
Predicate<T>
- Direct Known Subclasses:
InDateRange
,InTimeRange
public abstract class AbstractInTimeRange<T extends Comparable<T>> extends KoryphePredicate<T>
An
AbstractInTimeRange
is aPredicate
that tests if aComparable
is within a provided range [start, end]. By default the range is inclusive, you can toggle this using the startInclusive and endInclusive booleans.If the start is not set then this will be treated as unbounded. Similarly with the end.
If the test value is null then the predicate will return false.
This range predicate takes a single value to test, if you want to test a startValue and endValue lies within a range then you can use the
AbstractInTimeRangeDual
predicate.The range can also be configured using time offsets from the current system time or a provided start/end time. You can set the start and end offsets using startOffset and endOffset. By default the offset is measured in Days, this can be changed to DAY, HOUR, MINUTE, SECOND and MILLISECOND using the offsetUnit field.
At the point when test is called on the class the current system time is used to calculate the start and end values based on: System.currentTimeMillis() + offset.
You can configure the start and end time strings using one of the following formats:
- timestamp in milliseconds
- yyyy/MM
- yyyy/MM/dd
- yyyy/MM/dd HH
- yyyy/MM/dd HH:mm
- yyyy/MM/dd HH:mm:ss
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractInTimeRange.BaseBuilder<B extends AbstractInTimeRange.BaseBuilder<B,R,T>,R extends AbstractInTimeRange<T>,T extends Comparable<T>>
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getEnd()
Long
getEndOffset()
TimeUnit
getOffsetUnit()
String
getStart()
Long
getStartOffset()
TimeUnit
getTimeUnit()
TimeZone
getTimeZone()
String
getTimeZoneId()
int
hashCode()
Boolean
isEndInclusive()
Boolean
isStartInclusive()
boolean
test(T value)
String
toString()
-
-
-
Method Detail
-
test
public boolean test(T value)
-
getStart
public String getStart()
-
getStartOffset
public Long getStartOffset()
-
isStartInclusive
public Boolean isStartInclusive()
-
getEnd
public String getEnd()
-
getEndOffset
public Long getEndOffset()
-
isEndInclusive
public Boolean isEndInclusive()
-
getOffsetUnit
public TimeUnit getOffsetUnit()
-
getTimeUnit
public TimeUnit getTimeUnit()
-
getTimeZone
public TimeZone getTimeZone()
-
getTimeZoneId
public String getTimeZoneId()
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classKoryphePredicate<T extends Comparable<T>>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classKoryphePredicate<T extends Comparable<T>>
-
-