make RepoCreate.with immutable, #1664#1936
Open
edmoffo wants to merge 1 commit into
Open
Conversation
The RepoCreate.with(key, value) method mutated the internal map and returned the same instance. Add a private constructor that accepts the extra-fields map and have with(...) build a new RepoCreate with a fresh copy of the map plus the new entry. Add a test that asserts the original instance is left untouched and that successive with() calls accumulate. Closes jcabi#1664
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.
Resolves the puzzle filed as #1664.
Repos.RepoCreate.with(key, value)was mutating the internalothermap and returningthis, which contradicts the class invariant that every otherwith...method onRepoCreatereturns a new instance.A new private constructor accepts the extra-fields map, and
with(...)now builds a freshRepoCreatefrom a copy of the current map plus the new entry. The PDD puzzle marker is removed in the same change.mvn clean install -Pquliceandmvn -Pqulice testwere run locally on this branch; the full unit suite (734 tests, 0 failures) and the Qulice checks pass. Two new tests inRepoCreateTestcover the immutability contract and accumulation across successivewithcalls.Closes #1664