Replace MarketDataClient builder with explicit constructors#4
Merged
Conversation
|
The author of this PR, MarketDataDev03, is not an activated member of this organization on Codecov. |
MarketDataDev01
approved these changes
May 8, 2026
The previous commit dropped the (ADR-002) parentheticals from the exception
javadoc but the resulting reflow placed the leading words ("a", "{@code") at
the start of the next line. Spotless prefers them at the end of the previous
line; CI's spotlessJavaCheck flagged both files. This applies the
spotlessApply output verbatim — no behaviour or content change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Replace
MarketDataClientbuilder with explicit constructorsSummary
Removes the
MarketDataClient.Builderpattern in favour of two publicconstructors — a no-arg one for the production happy path (everything resolved
from the §4 cascade) and a 4-arg one for tests and short-lived runtimes that
need explicit control. All fields stay
final; the client remains immutable.Motivation
The previous
MarketDataClient.builder()...build()shape carried moreceremony than the surface warrants: the type has 4 settable knobs, three of
which are routinely left at their default. The team chose to favour a direct
constructor surface —
new MarketDataClient()for production andnew MarketDataClient(apiKey, baseUrl, apiVersion, validateOnStartup)for explicitcontrol — over the fluent builder, accepting the trade-off that adding a 5th
knob in the future will require either a new overload or a SemVer bump.
Changes
MarketDataClient(src/main/java/com/marketdata/sdk/MarketDataClient.java)Builderclass and thestatic Builder builder()factory.MarketDataClient()— production constructor. Delegates viathis(...)tothe master constructor with
null, null, null, true. All settings comefrom the cascade (env var →
.env→ built-in default); startup validationis enabled.
MarketDataClient(@Nullable String apiKey, @Nullable String baseUrl, @Nullable String apiVersion, boolean validateOnStartup)— masterconstructor. Holds the cascade-resolution and initialisation logic. Each
nullable parameter still falls back to the cascade for that single value.
final. The client is immutable.that instances are immutable.
Test suite (
src/test/java/com/marketdata/sdk/MarketDataClientTest.java).builder()...build()to thematching constructor invocation.
noArgConstructorAppliesProductionDefaults, thatexercises
new MarketDataClient()directly and asserts the contract:isValidateOnStartup()istrue(env-independent — encoded in the no-argconstructor).
getUserAgent()starts withmarketdata-sdk-java/.getBaseUrl()andgetApiVersion()fall back to the documented defaultswhen no
MARKETDATA_*env override is set (gated onSystem.getenvlikethe existing
demoModeWhenNoTokenAvailabletest).demoModeWhenNoTokenAvailabletest now usesnew MarketDataClient()(its assertion was already valid; the call site just dropped the
three-
nullclutter).