Skip to content

Add ExitStatus overload for on() method in builder classes#5325

Open
tahayigitmelek wants to merge 1 commit intospring-projects:mainfrom
tahayigitmelek:feature-5306-use-exitstatus-parameter-flowbuilder
Open

Add ExitStatus overload for on() method in builder classes#5325
tahayigitmelek wants to merge 1 commit intospring-projects:mainfrom
tahayigitmelek:feature-5306-use-exitstatus-parameter-flowbuilder

Conversation

@tahayigitmelek
Copy link

Fixes #5306

Motivation

The current .on(String pattern) method in builder classes requires developers to use string literals (e.g., "COMPLETED") to conditionally branch the flow. This approach is prone to typographical errors and does not leverage the predefined, type-safe constants provided by the ExitStatus class.

Furthermore, developers intuitively expect to pass an ExitStatus object since it represents the actual outcome of a step.


Proposed Change

Added on(ExitStatus status) methods as overloaded convenience methods that delegate directly to the existing .on(String pattern) methods by extracting the underlying exit code.


Benefits

Improved Type Safety

Allows using explicitly defined constants like ExitStatus.COMPLETED instead of "magic strings", significantly reducing the risk of typos.

Better IDE Support

Enhances developer experience through reliable code completion and static analysis features.

API Consistency

Standardizes flow transition declarations across the builder API, providing a unified and predictable developer experience.

Self-Documenting Code

Makes code more readable by explicitly showing that the transition depends on a predefined exit status.


Changes

  • SimpleJobBuilder.on(ExitStatus) → delegates to .on(String)
  • FlowBuilder.on(ExitStatus) → delegates to .on(String)
  • FlowBuilder.UnterminatedFlowBuilder.on(ExitStatus) → delegates to .on(String)

Backward Compatibility

The existing .on(String) methods remain for full backward compatibility, ensuring existing wildcard pattern matches (e.g., "FAIL*", "*", or "CUST?M") continue to function perfectly.

Introduce on(ExitStatus) method in builder classes for better type safety

Fixes [spring-projects#5306](spring-projects#5306)

Add on(ExitStatus) methods as overloaded convenience methods that delegate directly to the existing on(String) methods by extracting the underlying exit code. The new method names make the type-safe behavior explicit and improve API consistency across builder classes.

Changes:
- `SimpleJobBuilder.on(ExitStatus)` - delegates to on(String)
- `FlowBuilder.on(ExitStatus)` - delegates to on(String)
- `FlowBuilder.UnterminatedFlowBuilder.on(ExitStatus)` - delegates to on(String)

The existing on(String) methods remain for backward compatibility and to preserve wildcard pattern matching.

Signed-off-by: Taha Yigit Melek <yigittahamelek@gmail.com>
Signed-off-by: tahayigitmelek <yigittahamelek@gmail.com>
@tahayigitmelek tahayigitmelek force-pushed the feature-5306-use-exitstatus-parameter-flowbuilder branch from 023f5d2 to 70f26ee Compare March 9, 2026 20:15
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.

Use ExitStatus as parameter for Flowbuilder.on() method

1 participant