Table of Contents

NotableDateFilter Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
NotableDateFilter.cs

Represents a composable predicate over resolved NotableDate occurrences, used to restrict the results returned by INotableDateService to those matching a category, tag, name, duration, or observed-state criterion. This class cannot be inherited.

public sealed class NotableDateFilter
Inheritance
NotableDateFilter
Inherited Members
Extension Methods

Examples

INotableDateService service = AmericasCalendarData.CreateService("US");
DateRange year = new(new DateOnly(2026, 1, 1), new DateOnly(2026, 12, 31));

// Non-working public holidays only.
NotableDateFilter publicHolidays = NotableDateFilter
    .ForCategory(NotableDateCategory.PublicHoliday)
    .And(NotableDateFilter.IsNonWorkingDay());

IReadOnlyList<NotableDate> holidays = service.Resolve(year, "US", publicHolidays);

// Religious or cultural dates tagged "Christian", excluding observed substitutes.
NotableDateFilter christian = NotableDateFilter
    .ForAnyCategory(NotableDateCategory.Religious, NotableDateCategory.Cultural)
    .And(NotableDateFilter.WithTag("Christian"))
    .And(NotableDateFilter.WasAdjusted().Not());

IReadOnlyList<NotableDate> observances = service.Resolve(year, "US", christian);

Remarks

Construction. A filter is created through the static factory methods on this class - for example ForCategory(NotableDateCategory), WithTag(string), IsNonWorkingDay(), and InDateRange(DateOnly, DateOnly). There is no public constructor; every factory returns an immutable instance.

Composition. Filters combine through the instance operators And(NotableDateFilter), Or(NotableDateFilter), and Not(), and the variadic factories AllOf(params NotableDateFilter[]) and AnyOf(params NotableDateFilter[]). Because every instance is immutable, composition always produces a new filter and never mutates an operand, so a filter can be cached and reused across queries and threads.

Evaluation. A filter is evaluated against each materialized occurrence after resolution: pass a filter to one of the Resolve overloads on INotableDateService (which keeps only the occurrences for which Matches(NotableDate) returns true), or call Matches(NotableDate) directly to test a single occurrence.

Methods

AllOf(params NotableDateFilter[])

Creates a filter that matches an occurrence only when every supplied filter matches it.

public static NotableDateFilter AllOf(params NotableDateFilter[] filters)

Parameters

filters NotableDateFilter[]

The filters that must all match.

Returns

NotableDateFilter

A filter matching the conjunction of the supplied filters.

Exceptions

ArgumentNullException

filters is null.

And(NotableDateFilter)

Combines this filter with another so that both must match.

public NotableDateFilter And(NotableDateFilter other)

Parameters

other NotableDateFilter

The filter to combine with.

Returns

NotableDateFilter

A filter matching the conjunction of the two filters.

Exceptions

ArgumentNullException

other is null.

AnyOf(params NotableDateFilter[])

Creates a filter that matches an occurrence when any supplied filter matches it.

public static NotableDateFilter AnyOf(params NotableDateFilter[] filters)

Parameters

filters NotableDateFilter[]

The filters, any of which may match.

Returns

NotableDateFilter

A filter matching the disjunction of the supplied filters.

Exceptions

ArgumentNullException

filters is null.

ForAnyCategory(params NotableDateCategory[])

Creates a filter that matches occurrences belonging to any of the supplied categories.

public static NotableDateFilter ForAnyCategory(params NotableDateCategory[] categories)

Parameters

categories NotableDateCategory[]

The categories to match.

Returns

NotableDateFilter

A filter matching any of the categories.

Exceptions

ArgumentNullException

categories is null.

ForCategory(NotableDateCategory)

Creates a filter that matches occurrences of a specific category.

public static NotableDateFilter ForCategory(NotableDateCategory category)

Parameters

category NotableDateCategory

The category to match.

Returns

NotableDateFilter

A filter matching the category.

InDateRange(DateOnly, DateOnly)

Creates a filter that matches occurrences whose emitted date falls within an inclusive date range.

public static NotableDateFilter InDateRange(DateOnly startInclusive, DateOnly endInclusive)

Parameters

startInclusive DateOnly

The inclusive start date.

endInclusive DateOnly

The inclusive end date.

Returns

NotableDateFilter

A filter matching occurrences within the range.

IsNonWorkingDay()

Creates a filter that matches occurrences flagged as non-working days.

public static NotableDateFilter IsNonWorkingDay()

Returns

NotableDateFilter

A filter matching non-working occurrences.

Matches(NotableDate)

Determines whether the supplied occurrence satisfies the filter.

public bool Matches(NotableDate notableDate)

Parameters

notableDate NotableDate

The resolved occurrence to test.

Returns

bool

true if the occurrence matches; otherwise false.

Exceptions

ArgumentNullException

notableDate is null.

Not()

Negates this filter.

public NotableDateFilter Not()

Returns

NotableDateFilter

A filter matching exactly the occurrences this filter does not.

Or(NotableDateFilter)

Combines this filter with another so that either may match.

public NotableDateFilter Or(NotableDateFilter other)

Parameters

other NotableDateFilter

The filter to combine with.

Returns

NotableDateFilter

A filter matching the disjunction of the two filters.

Exceptions

ArgumentNullException

other is null.

WasAdjusted()

Creates a filter that matches occurrences whose emitted date differs from the calculated date because an adjustment applied.

public static NotableDateFilter WasAdjusted()

Returns

NotableDateFilter

A filter matching observed (adjusted) occurrences.

WithAllTags(params string[])

Creates a filter that matches occurrences carrying all of the supplied tags.

public static NotableDateFilter WithAllTags(params string[] tags)

Parameters

tags string[]

The tags that must all be present.

Returns

NotableDateFilter

A filter matching occurrences with every tag.

Exceptions

ArgumentNullException

tags is null.

WithAnyName(params string[])

Creates a filter that matches occurrences whose display name equals any of the supplied names.

public static NotableDateFilter WithAnyName(params string[] displayNames)

Parameters

displayNames string[]

The display names to match.

Returns

NotableDateFilter

A filter matching any of the names.

Exceptions

ArgumentNullException

displayNames is null.

WithAnyTag(params string[])

Creates a filter that matches occurrences carrying any of the supplied tags.

public static NotableDateFilter WithAnyTag(params string[] tags)

Parameters

tags string[]

The tags to match.

Returns

NotableDateFilter

A filter matching occurrences with any of the tags.

Exceptions

ArgumentNullException

tags is null.

WithId(string)

Creates a filter that matches occurrences produced by a specific notable-date concept identifier.

public static NotableDateFilter WithId(string notableDateId)

Parameters

notableDateId string

The notable-date concept identifier to match.

Returns

NotableDateFilter

A filter matching the concept identifier.

Exceptions

ArgumentNullException

notableDateId is null.

WithMinDuration(int)

Creates a filter that matches occurrences spanning at least the supplied number of days.

public static NotableDateFilter WithMinDuration(int days)

Parameters

days int

The minimum inclusive duration in days.

Returns

NotableDateFilter

A filter matching occurrences of at least the duration.

WithName(string)

Creates a filter that matches occurrences with a specific display name.

public static NotableDateFilter WithName(string displayName)

Parameters

displayName string

The display name to match.

Returns

NotableDateFilter

A filter matching the display name.

Exceptions

ArgumentNullException

displayName is null.

WithTag(string)

Creates a filter that matches occurrences carrying a specific tag.

public static NotableDateFilter WithTag(string tag)

Parameters

tag string

The tag to match.

Returns

NotableDateFilter

A filter matching occurrences with the tag.

Exceptions

ArgumentNullException

tag is null.

Applies to

ProductVersions
.NET8, 10

See Also