Package javax.time.calendar
Class CalendricalMatchers.DayOfWeekInMonth
- java.lang.Object
-
- javax.time.calendar.CalendricalMatchers.DayOfWeekInMonth
-
- All Implemented Interfaces:
java.io.Serializable,CalendricalMatcher
- Enclosing class:
- CalendricalMatchers
private static final class CalendricalMatchers.DayOfWeekInMonth extends java.lang.Object implements CalendricalMatcher, java.io.Serializable
Class implementing day-of-week in month matcher.
-
-
Field Summary
Fields Modifier and Type Field Description private DayOfWeekdayOfWeekThe day-of-week.private intordinalThe ordinal, from 1 to 5.private static longserialVersionUIDA serialization identifier for this class.
-
Constructor Summary
Constructors Modifier Constructor Description privateDayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)inthashCode()booleanmatchesCalendrical(Calendrical calendrical)Checks if the input calendrical matches the rules of the implementation.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
ordinal
private final int ordinal
The ordinal, from 1 to 5.
-
dayOfWeek
private final DayOfWeek dayOfWeek
The day-of-week.
-
-
Constructor Detail
-
DayOfWeekInMonth
private DayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek)Constructor.- Parameters:
ordinal- ordinal, from 1 to 5dayOfWeek- the day-of-week, not null
-
-
Method Detail
-
matchesCalendrical
public boolean matchesCalendrical(Calendrical calendrical)
Checks if the input calendrical matches the rules of the implementation.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); }- Specified by:
matchesCalendricalin interfaceCalendricalMatcher- Parameters:
calendrical- the calendrical to match against, not null- Returns:
- true if the date matches, false otherwise
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-