mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Move LocalDate injection to the Actions themselves
We want to make it clear what query (or POST) inputs the user needs to / can give for each Action. That means moving all the @Injects of these parameters to the Actions themselves instead of injecting them in "hidden" indirect dependencies. This has the extra benefit of allowing these indirect dependencies to work for JSON Actions as well, since the "regular" way we @Inject parameters can corrupt the POST JSON data. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232540758
This commit is contained in:
parent
89802329b3
commit
927e8bbd73
7 changed files with 30 additions and 20 deletions
|
@ -83,7 +83,8 @@ public class ReportingModule {
|
|||
*/
|
||||
@Provides
|
||||
static YearMonth provideYearMonth(
|
||||
@Parameter(PARAM_YEAR_MONTH) Optional<YearMonth> yearMonthOptional, LocalDate date) {
|
||||
@Parameter(PARAM_YEAR_MONTH) Optional<YearMonth> yearMonthOptional,
|
||||
@Parameter(PARAM_DATE) LocalDate date) {
|
||||
return yearMonthOptional.orElseGet(() -> new YearMonth(date.minusMonths(1)));
|
||||
}
|
||||
|
||||
|
@ -108,9 +109,10 @@ public class ReportingModule {
|
|||
* current date.
|
||||
*/
|
||||
@Provides
|
||||
static LocalDate provideDate(
|
||||
@Parameter(PARAM_DATE) Optional<LocalDate> dateOptional, Clock clock) {
|
||||
return dateOptional.orElseGet(() -> new LocalDate(clock.nowUtc(), DateTimeZone.UTC));
|
||||
@Parameter(PARAM_DATE)
|
||||
static LocalDate provideDate(HttpServletRequest req, Clock clock) {
|
||||
return provideDateOptional(req)
|
||||
.orElseGet(() -> new LocalDate(clock.nowUtc(), DateTimeZone.UTC));
|
||||
}
|
||||
|
||||
/** Constructs a {@link Dataflow} API client with default settings. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue