Repository navigation
Add static factory methods as initial transitions - #6
Merged
Merged
Conversation
Methods returning the class type with a @refinement on a state of `return` (e.g. @refinement("maybeTime(return)")) are now initial transitions in the state machine, labelled like UUID.fromString(String). In classes they must be static; in external-refinements interfaces any method returning the class type counts. Interfaces with factory methods but no constructor no longer get the implicit default initial state. Closes #5 Co-Authored-By: Claude Opus 5.5 (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.
Closes #5.
Summary
@Refinementthat names a state onreturn, e.g.@Refinement("maybeTime(return)").static. In external-refinements interfaces (wherestaticcan't be declared) any method returning the class type counts.flag ? open(return) : closed(return)gives two initial transitions, guarded byflagand!flag.constructorSignaturefield, labelled likeUUID.fromString(String).new X().Tests
Three new tests: a class with static factories (plus a non-static method and a non-class-returning method that are ignored), the UUID interface from the issue, and an interface with factories but no constructor.
mvn test: 23 tests, all pass.🤖 Generated with Claude Code