Skip to content

make RepoCreate.with immutable, #1664#1936

Open
edmoffo wants to merge 1 commit into
jcabi:masterfrom
edmoffo:1664-immutable-with-method
Open

make RepoCreate.with immutable, #1664#1936
edmoffo wants to merge 1 commit into
jcabi:masterfrom
edmoffo:1664-immutable-with-method

Conversation

@edmoffo

@edmoffo edmoffo commented Jun 18, 2026

Copy link
Copy Markdown

Resolves the puzzle filed as #1664. Repos.RepoCreate.with(key, value) was mutating the internal other map and returning this, which contradicts the class invariant that every other with... method on RepoCreate returns a new instance.

A new private constructor accepts the extra-fields map, and with(...) now builds a fresh RepoCreate from a copy of the current map plus the new entry. The PDD puzzle marker is removed in the same change.

mvn clean install -Pqulice and mvn -Pqulice test were run locally on this branch; the full unit suite (734 tests, 0 failures) and the Qulice checks pass. Two new tests in RepoCreateTest cover the immutability contract and accumulation across successive with calls.

Closes #1664

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
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.

Repos.java:377-381: Make 'with' method immutable....

1 participant