Extract base classes to reduce request and search DTO boilerplate.#249
Draft
mikism wants to merge 1 commit into
Draft
Extract base classes to reduce request and search DTO boilerplate.#249mikism wants to merge 1 commit into
mikism wants to merge 1 commit into
Conversation
86980b1 to
248792b
Compare
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).
248792b to
e6b3840
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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).
Search class and reference it from ArrivalSearches.
Request DTOs:
abstract endpoint() and acceptType() hooks, and move createPostRequest
out of TravelTimeRequest into it.
arrival, intersections and unions fields plus the endpoint across the
TimeMap(Fast) JSON, WKT, KML, GeoJSON and boxes variants.
JSON media type as protected for the subclasses.
Tests & fixtures:
field serialisation order (inherited base fields are emitted before the
subclass-specific ones).