Skip to content

Add org.cactoos.map.Immutable decorator - #1845

Open
rehandxtr wants to merge 1 commit into
yegor256:masterfrom
rehandxtr:rehan_Split_Map_issue_fix
Open

Add org.cactoos.map.Immutable decorator#1845
rehandxtr wants to merge 1 commit into
yegor256:masterfrom
rehandxtr:rehan_Split_Map_issue_fix

Conversation

@rehandxtr

@rehandxtr rehandxtr commented Jan 21, 2026

Copy link
Copy Markdown

Summary

Adds org.cactoos.map.Immutable, a read-only Map decorator aligned with the existing list.Immutable / set.Immutable pattern, plus documentation and tests.

This PR also documents the existing SplitPreserveAllTokens API in the README and adds focused tests for TriFuncSplitPreserve (the implementation itself is already on master).

Closes #1835

Relates to #1722 (docs/tests only — implementation already merged)

Changes

Area Details
New src/main/java/org/cactoos/map/Immutable.java — blocks put / remove / putAll / clear, immutable views (keySet, values, entrySet), and Entry.setValue()
Tests ImmutableTest (map decorator behavior and mutation rejection)
Tests TriFuncSplitPreserveTest (core split-preserve algorithm coverage)
Docs README sections for splitting text / preserving empty tokens, Maps / Immutable maps, and comparison-table entries
CI Maven matrix kept on ubuntu-24.04, windows-2022, macos-15; pass -Dhone.skipWithoutDocker=true / -Dhone.skipOnWindows=true so hone runs on Ubuntu (Docker available) and is skipped cleanly on macOS/Windows

Design notes

  • Implements Map directly (same approach as other Immutable decorators in this codebase), not via MapEnvelope.
  • Decorator semantics: it is a view, not a defensive copy. Underlying map mutations through another reference remain visible; callers who need a snapshot should copy first.
  • Constructor accepts Map<? extends K, ? extends V> for covariance, consistent with typical Cactoos collection decorators.
  • README documents SplitPreserveAllTokens for discoverability; that class is not introduced by this PR (already present on master).

Test plan

  • ImmutableTest — mutation attempts throw UnsupportedOperationException; views/iterators/entry updates are blocked; read operations delegate correctly
  • TriFuncSplitPreserveTest — delimiter / limit / empty-token edge cases
  • CI green on ubuntu-24.04, windows-2022, and macos-15

Commit hygiene

History kept to a single commit on rehan_Split_Map_issue_fix for a clean review surface.

@rehandxtr
rehandxtr marked this pull request as draft January 21, 2026 15:51
@rehandxtr
rehandxtr marked this pull request as ready for review June 24, 2026 15:53
@rehandxtr
rehandxtr force-pushed the rehan_Split_Map_issue_fix branch from 5baa090 to b61c74d Compare June 24, 2026 16:10
@rehandxtr rehandxtr changed the title Added Splitting Text and implemented Immutable Maps Add org.cactoos.map.Immutable decorator Jun 24, 2026
@rehandxtr

Copy link
Copy Markdown
Author

PR hygiene pass (findings)

Cleaned up this PR for review. Summary of what changed and what reviewers should know:

Done

Item Status
Single commit Squashed 6 commits → 1 (b61c74d). Prior history mixed merge/conflict resolution, qulice fixes, README lint, and CI matrix tweaks.
Title Renamed from “Added Splitting Text and implemented Immutable Maps”“Add org.cactoos.map.Immutable decorator” (matches the real delta vs master).
Description Replaced outdated body (placeholder issue links, claims of introducing split-preserve implementation, inflated test counts) with an accurate summary, change table, design notes, and test plan.
Issue linkage Closes #1835 for the map decorator. #1722 noted as docs/tests onlySplitPreserveAllTokens / TriFuncSplitPreserve sources are already on master.

Scope vs master (what this PR actually ships)

5 files, +955 / −21:

  1. src/main/java/org/cactoos/map/Immutable.javanew read-only Map decorator
  2. src/test/java/org/cactoos/map/ImmutableTest.javanew tests
  3. src/test/java/org/cactoos/func/TriFuncSplitPreserveTest.javanew tests for existing func
  4. README.md — docs for maps/immutable maps + split-preserve usage examples & comparison table rows
  5. .github/workflows/mvn.yml — Maven job matrix restricted to ubuntu-24.04 (hone/Docker constraint)

Important corrections from the previous description

  • Not introducing SplitPreserveAllTokens / TriFuncSplitPreserve implementations — those paths are identical on master and this branch. This PR only documents them and adds TriFuncSplitPreserveTest.
  • Previous body referenced “Closes #XXX / #YYY” and “100 tests”; the live suite here is focused on ImmutableTest + TriFuncSplitPreserveTest (not 49+34+17 as claimed).
  • Primary functional deliverable for review is org.cactoos.map.Immutable addressing Let's implement a Immutable Map decorator #1835.

Design notes worth a quick maintainer look

  • Follows the existing list/set Immutable pattern (implements Map directly; mutation methods throw UnsupportedOperationException).
  • Documented as a decorator/view, not a snapshot — correct for the issue, but worth confirming against maintainer preference.
  • CI matrix change is orthogonal to the feature: it avoids failing/non-functional macos/windows runners for hone-maven-plugin/Docker. Maintainers may prefer splitting that into a dedicated CI PR.

Permissions note (labels / formal reviewer request)

As the PR author on a fork, this account cannot apply labels or formally request reviewers on yegor256/cactoos (API returns 403/404 for those operations). Suggested maintainer actions:

  • Add label: enhancement (optional: role/REV if that is how you triage)
  • Formal review request: @yegor256 (repo owner/admin)

Suggested review focus for @yegor256

  1. Accept map.Immutable API/style vs other Cactoos Immutable types
  2. Confirm README additions (especially split-preserve section) are desirable alongside the map work
  3. Decide whether the Maven OS matrix change belongs in this PR or should be reverted/split out

Happy to adjust further if anything above should land differently.

@rehandxtr
rehandxtr force-pushed the rehan_Split_Map_issue_fix branch 3 times, most recently from a452a16 to 15f4e48 Compare June 24, 2026 16:32
Introduce a read-only Map decorator consistent with list/set Immutable
classes, document usage in the README (including SplitPreserveAllTokens
examples for the existing text API), and add unit tests for map.Immutable
and TriFuncSplitPreserve.

Keep the Maven CI matrix on ubuntu-24.04, windows-2022, and macos-15.
Pass -Dhone.skipWithoutDocker=true so hone runs when Docker is present
(Ubuntu) and is skipped cleanly on runners without Docker.

Closes yegor256#1835
@rehandxtr
rehandxtr force-pushed the rehan_Split_Map_issue_fix branch from 15f4e48 to b6441ad Compare June 24, 2026 16:41
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.

Let's implement a Immutable Map decorator

1 participant