Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support injection of arbitrary types via ValidationContext #1607

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

aababilov
Copy link
Collaborator

ValidationContext is used to inject params to constructors of *Validator classes. ValidationContext initially supported only CountryCode and CurrentDateTime, e.g.:

@Inject
ExpiredCalendarValidator(
CurrentDateTime currentDateTime, // Injected from ValidationContext
GtfsCalendarTableContainer calendarTable,
GtfsCalendarDateTableContainer calendarDateTable) {...}

This change allows the user to inject any types required for custom validation logic.

ValidationContext is used to inject params to constructors of *Validator
classes. ValidationContext initially supported only CountryCode and
CurrentDateTime, e.g.:

  @Inject
  ExpiredCalendarValidator(
      CurrentDateTime currentDateTime, // Injected from ValidationContext
      GtfsCalendarTableContainer calendarTable,
      GtfsCalendarDateTableContainer calendarDateTable) {...}

This change allows the user to inject any types required for custom
validation logic.
private final ImmutableMap<Class<?>, Object> context;

private ValidationContext(ImmutableMap<Class<?>, Object> context) {
this.context = context;
}

/**
* Represents a name of a GTFS feed, such as "nl-openov".
*
* @return the @code{GtfsFeedName} representing the feed's name
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated to your PR, but this method comment seems incorrect. Understood if you don't want to fix it here, but if you were willing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's fix it while I am here. This comment is pretty confusing.

@bdferris-v2
Copy link
Collaborator

Added @davidgamez as an FYI.

@aababilov
Copy link
Collaborator Author

Thanks a lot for the quick review!

@aababilov aababilov merged commit c0cd6be into MobilityData:master Nov 22, 2023
332 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants