Skip to content

feat: add per-date factory for date metadata provider - #9884

Merged
web-padawan merged 1 commit into
mainfrom
feat/date-picker-per-date-metadata
Aug 14, 2026
Merged

web-padawan merged 1 commit into
mainfrom
feat/date-picker-per-date-metadata

Conversation

@web-padawan

Copy link
Copy Markdown
Member

DateMetadataProvider is called with a range of dates, so a rule that only looks at one date at a time has to iterate the range and collect the entries by hand:

datePicker.setDateMetadataProvider(
        range -> range.start().datesUntil(range.end().plusDays(1))
                .filter(date -> isFullyBooked(date))
                .map(date -> new DateMetadata(date, true))
                .toList());

For rules that answer from memory, that is boilerplate. The new factory takes a function from a date to its metadata, or null for a date that has none:

datePicker.setDateMetadataProvider(DateMetadataProvider.perDate(
        date -> isFullyBooked(date) ? new DateMetadata(date, true) : null));

Changes

The factory is a static method on DateMetadataProvider, not a new setter on the components. setDateMetadataProvider stays the only entry point, getDateMetadataProvider() keeps a single answer, and nothing has to be mirrored on Date Time Picker later.

The function runs once per date in the requested range, which can cover up to a year. The Javadoc says it has to answer from memory, and points rules that query a backend at implementing the provider directly, where a single query can answer for the whole range. Making the per-date shape look this convenient is exactly how a query-per-date ends up in an application, so the warning sits on the factory itself.

Part of vaadin/platform#2867


🤖 Generated with Claude Code

For rules that can answer from memory, iterating the range and collecting
entries by hand is boilerplate. DateMetadataProvider.perDate(...) takes a
function from a date to its metadata, or null for none, and handles the
iteration:

    datePicker.setDateMetadataProvider(DateMetadataProvider.perDate(
            date -> isFullyBooked(date) ? new DateMetadata(date, true)
                    : null));

The function runs once per date in the requested range, so its Javadoc
points backend-backed rules at implementing the provider directly, where
a single query answers for the whole range.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@web-padawan
web-padawan marked this pull request as ready for review August 14, 2026 12:48
@web-padawan
web-padawan requested a review from vursen August 14, 2026 12:48

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Nothing to flag — the changes look good.

@sonarqubecloud

Copy link
Copy Markdown

@web-padawan
web-padawan added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit 453984b Aug 14, 2026
25 checks passed
@web-padawan
web-padawan deleted the feat/date-picker-per-date-metadata branch August 14, 2026 19:30
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.3.0-alpha9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants