Class GeoTemporalApplicability
- java.lang.Object
-
- org.sellcom.geotemporal.time.applicability.GeoTemporalApplicability
-
- All Implemented Interfaces:
BiPredicate<Temporal,GeoRegion>,GeoTemporalPredicate
- Direct Known Subclasses:
TemporalApplicability
public abstract class GeoTemporalApplicability extends Object implements GeoTemporalPredicate
Applicability at aTemporalin aGeoRegion.
-
-
Constructor Summary
Constructors Constructor Description GeoTemporalApplicability()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static GeoTemporalApplicabilityholiday(EnumSet<HolidayType> types)Creates an applicability satisfied on holidays of any of the given types.static GeoTemporalApplicabilityparse(String expression)Creates an applicability satisfied when the given expression evaluates totrue.static GeoTemporalApplicabilitypublicHoliday()Creates an applicability satisfied on public holidays.static GeoTemporalApplicabilityschoolHoliday()Creates an applicability satisfied on school holidays.abstract booleantest(Temporal temporal, GeoRegion region)Checks whether this applicability is satisfied at the given temporal in the given region.static GeoTemporalApplicabilityweekend()Creates an applicability satisfied on weekends.static GeoTemporalApplicabilityworkingDay()Creates an applicability satisfied on working days.-
Methods inherited from interface java.util.function.BiPredicate
and, negate, or
-
-
-
-
Method Detail
-
holiday
public static GeoTemporalApplicability holiday(EnumSet<HolidayType> types)
Creates an applicability satisfied on holidays of any of the given types.- Since:
- 1.0
-
parse
public static GeoTemporalApplicability parse(String expression)
Creates an applicability satisfied when the given expression evaluates totrue. The expression must be a Boolean expression composed of a combination of the Boolean constants "true" and "false", temporal predicates (see below), Boolean operators "and", "or", and "not", and parentheses "(" and ")".Examples
Example geo-temporal expressions Expression Meaning (singleMonth[Sep] or singleMonth[Dec]) and singleDayOfWeek[Sat]Saturdays in September and December monthDayRange[10-15,10-29] and singleDayOfWeek[Fri]Fridays between 15 October and 29 October (both dates inclusive) Supported date predicates
Predicates supported in geo-temporal expressions Syntax Description Example Meaning dateRange[YYYY-MM-DD,YYYY-MM-DD]range of dates
(seeTemporalApplicability.dateRange(LocalDate, LocalDate))dateRange[2015-10-15,2015-10-29]15 October 2015 to 29 October 2015 dayOfWeekAfter[N,U,MM-DD]nth day-of-week after a month-day
(seeTemporalApplicability.dayOfWeekAfter(int, DayOfWeek, MonthDay))dayOfWeekAfter[4,Thu,10-31]fourth Thursday after 31 October, fourth Thursday in November dayOfWeekBefore[N,U,MM-DD]nth day-of-week before a month-day
(seeTemporalApplicability.dayOfWeekBefore(int, DayOfWeek, MonthDay))dayOfWeekBefore[1,Sun,12-25]first Sunday before 25 December dayOfWeekRange[U,U]range of days-of-week
(seeTemporalApplicability.dayOfWeekRange(DayOfWeek, DayOfWeek))dayOfWeekRange[Fri,Sun]Friday to Sunday falsenever
(seeTemporalApplicability.never())falsenever holiday[T...]holiday of any of the given types
(seeholiday(EnumSet))holiday[P]public holidays isoWeek[even]weeks with even ISO week number
(seeTemporalApplicability.evenIsoWeek())isoWeek[even]weeks with even ISO week number isoWeek[odd]weeks with odd ISO week number
(seeTemporalApplicability.oddIsoWeek())isoWeek[odd]weeks with odd ISO week number isoWeekRange[W,W]weeks with ISO week numbers from the given range
(seeTemporalApplicability.isoWeekRange(int, int))isoWeekRange[5,9]weeks with ISO week numbers 5 to 9 monthDayRange[MM-DD,MM-DD]range of month-days
(seeTemporalApplicability.monthDayRange(MonthDay, MonthDay))monthDayRange[10-15,10-29]15 October to 29 October monthRange[MM,MM]range of months-of-year
(seeTemporalApplicability.monthRange(Month, Month))monthRange[10,12]October to December publicHoliday[]single date
(seepublicHoliday())publicHoliday[]public holidays schoolHoliday[]single date
(seeschoolHoliday())schoolHoliday[]school holidays singleDate[YYYY-MM-DD]single date
(seeTemporalApplicability.singleDate(LocalDate))singleDate[2015-10-15]15 October 2015 singleDayOfWeek[U]single day-of-week
(seeTemporalApplicability.singleDayOfWeek(DayOfWeek))singleDayOfWeek[Fri]Friday singleIsoWeek[W]weeks with ISO week number
(seeTemporalApplicability.singleIsoWeek(int))singleIsoWeek[42]weeks with ISO week number 42 singleMonth[MM]single month-of-year
(seeTemporalApplicability.singleMonth(Month))singleMonth[10]October singleMonthDay[MM-DD]single month-day
(seeTemporalApplicability.singleMonthDay(MonthDay))singleMonthDay[10-15]15 October singleYear[YYYY]single year
(seeTemporalApplicability.singleYear(int))singleYear[2015]2015 truealways
(seeTemporalApplicability.always())truealways weekend[]weekend days
(seeweekend())weekend[]weekend days workingDay[]working days
(seeworkingDay())workingDay[]working days yearRange[YYYY,YYYY]range of years
(seeTemporalApplicability.yearRange(int, int))year[2014,2015]2014 to 2015 Constants for holiday types
Constants for holiday types supported in geo-temporal predicates Constant Meaning B holidays observed only by banks and (most) financial institutions
(seeHolidayType.BANKS_AND_FINANCIAL_INSTITUTIONS_ONLY)G holidays observed only by government services
(seeHolidayType.GOVERNMENT_SERVICES_ONLY)P holidays observed globally
(seeHolidayType.PUBLIC)S holidays observed only by schools
(seeHolidayType.SCHOOLS_ONLY)U holidays observed only by schools and universities
(seeHolidayType.SCHOOLS_AND_UNIVERSITIES_ONLY)- Throws:
GeoTemporalApplicabilityParseException- if the expression cannot be parsedIllegalArgumentException- ifexpressionisnullor empty- Since:
- 1.0
-
publicHoliday
public static GeoTemporalApplicability publicHoliday()
Creates an applicability satisfied on public holidays.Only considers public holidays (
HolidayType.PUBLIC). To customise the holiday types, useholiday(EnumSet)instead.- Since:
- 1.0
-
schoolHoliday
public static GeoTemporalApplicability schoolHoliday()
Creates an applicability satisfied on school holidays.Only considers school holidays (
HolidayType.SCHOOLS_AND_UNIVERSITIES_ONLYandHolidayType.SCHOOLS_ONLY). To customise the holiday types, useholiday(EnumSet)instead.- Since:
- 1.0
-
test
public abstract boolean test(Temporal temporal, GeoRegion region)
Checks whether this applicability is satisfied at the given temporal in the given region.- Specified by:
testin interfaceBiPredicate<Temporal,GeoRegion>- Specified by:
testin interfaceGeoTemporalPredicate- Throws:
IllegalArgumentException- iftemporalisnullIllegalArgumentException- ifregionisnull- Since:
- 1.0
-
weekend
public static GeoTemporalApplicability weekend()
Creates an applicability satisfied on weekends.- Since:
- 1.0
-
workingDay
public static GeoTemporalApplicability workingDay()
Creates an applicability satisfied on working days.- Since:
- 1.2
-
-