Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Support mutable state in PersistentBehavior #25740
The reason we only support immutable state is that it is stored as snapshot asynchronously.
For Java it's cumbersome to be strictly immutable, and less familiar.
The builders for event and command dispatch work fine when defined outside the State, but if we want to support a ADT style where the actual logic of how to apply the events is defined in the concrete State classes. Due to lack of pattern matching in Java we would have to use builders for matching on the events, but creating a new builder for each invocation seems very wasteful and contradicts the idea that a builder is created once to construct the function, which is then invoked many times.
Two solutions were suggested:
Some experiments in #25729