public interface CalendricalMatcher
Matchers can be used to query the calendrical in unusual ways. Examples might be a matcher that checks if the date is a weekend or holiday, or Friday the Thirteenth.
CalendricalMatcher is an interface and must be implemented with care to ensure other classes in the framework operate correctly. All instantiable implementations must be final, immutable and thread-safe.
Modifier and Type | Method and Description |
---|---|
boolean |
matchesCalendrical(Calendrical calendrical)
Checks if the input calendrical matches the rules of the implementation.
|
boolean matchesCalendrical(Calendrical calendrical)
This is a strategy pattern that allows a range of matches to be made against a calendrical. A typical implementation will query the calendrical to extract one of more values, and compare or check them in some way.
For example, an implementation to check if the calendrical represents a Saturday or Sunday:
public boolean matchesCalendrical(Calendrical calendrical) { DayOfWeek dow = calendrical.get(ISOChronology.dayOfWeekRule()); return dow != null && (dow == DayOfWeek.SATURDAY || dow == DayOfWeek.SUNDAY); }
calendrical
- the calendrical to match against, not nullCopyright © 2014. All rights reserved.