Skip to content

Extract base classes to reduce request and search DTO boilerplate.#249

Draft
mikism wants to merge 1 commit into
masterfrom
refactoring/reducing_boilerplate
Draft

Extract base classes to reduce request and search DTO boilerplate.#249
mikism wants to merge 1 commit into
masterfrom
refactoring/reducing_boilerplate

Conversation

@mikism

@mikism mikism commented May 26, 2026

Copy link
Copy Markdown
Contributor

Pull duplicated fields and request-building logic into shared abstract
base classes, leaning on Lombok's @SuperBuilder/@Getter/@EqualsAndHashCode
(callSuper = true) in place of the per-class @Value/@Builder/@DaTa setup.

Search DTOs:

  • Add an abstract BaseSearch holding the fields common to ArrivalSearch
    and DepartureSearch in the postcodes, routes, timefilter, timefilterfast,
    timemap and zones packages; the concrete classes now only declare their
    distinguishing fields (e.g. arrivalTime / departureTime).
  • Merge the identical timemapfast ManyToOne and OneToMany into a single
    Search class and reference it from ArrivalSearches.

Request DTOs:

  • Add BaseTravelTimePostRequest centralising POST request creation behind
    abstract endpoint() and acceptType() hooks, and move createPostRequest
    out of TravelTimeRequest into it.
  • Add BaseTimeMapRequest / BaseTimeMapFastRequest sharing the departure,
    arrival, intersections and unions fields plus the endpoint across the
    TimeMap(Fast) JSON, WKT, KML, GeoJSON and boxes variants.
  • TravelTimeRequest gains @SuperBuilder/@NoArgsConstructor and exposes the
    JSON media type as protected for the subclasses.

Tests & fixtures:

  • Update request unit tests and the expected JSON fixtures to match the new
    field serialisation order (inherited base fields are emitted before the
    subclass-specific ones).

@mikism mikism self-assigned this May 26, 2026
@mikism mikism force-pushed the refactoring/reducing_boilerplate branch 8 times, most recently from 86980b1 to 248792b Compare May 27, 2026 10:32
Pull duplicated fields and request-building logic into shared abstract
base classes, leaning on Lombok's @SuperBuilder/@Getter/@EqualsAndHashCode
(callSuper = true) in place of the per-class @Value/@Builder/@DaTa setup.

Search DTOs:
- Add an abstract BaseSearch holding the fields common to ArrivalSearch
  and DepartureSearch in the postcodes, routes, timefilter, timefilterfast,
  timemap and zones packages; the concrete classes now only declare their
  distinguishing fields (e.g. arrivalTime / departureTime).
- Merge the identical timemapfast ManyToOne and OneToMany into a single
  Search class and reference it from ArrivalSearches.

Request DTOs:
- Add BaseTravelTimePostRequest centralising POST request creation behind
  abstract endpoint() and acceptType() hooks, and move createPostRequest
  out of TravelTimeRequest into it.
- Add BaseTimeMapRequest / BaseTimeMapFastRequest sharing the departure,
  arrival, intersections and unions fields plus the endpoint across the
  TimeMap(Fast) JSON, WKT, KML, GeoJSON and boxes variants.
- TravelTimeRequest gains @SuperBuilder/@NoArgsConstructor and exposes the
  JSON media type as protected for the subclasses.

Tests & fixtures:
- Update request unit tests and the expected JSON fixtures to match the new
  field serialisation order (inherited base fields are emitted before the
  subclass-specific ones).
@mikism mikism force-pushed the refactoring/reducing_boilerplate branch from 248792b to e6b3840 Compare May 27, 2026 12:18
@mikism mikism changed the title WIP Extract base classes to reduce request and search DTO boilerplate. May 27, 2026
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.

1 participant