Skip to content

fix: Introduce fluent pattern for StopWatch#1612

Closed
larshelge wants to merge 4 commits intoapache:masterfrom
larshelge:master
Closed

fix: Introduce fluent pattern for StopWatch#1612
larshelge wants to merge 4 commits intoapache:masterfrom
larshelge:master

Conversation

@larshelge
Copy link
Contributor

@larshelge larshelge commented Mar 5, 2026

This PR introduces fluent pattern for StopWatch. The goal is to improve readability and maintainability of code using StopWatch by creating a sentence-like flow of operations.

When using StopWatch the calling code gets a little verbose with operations on short, separate lines:

StopWatch watch = StopWatch.createStarted();
// Do work
watch.split();
log.info(watch.toString());
// Do work
watch.stop();
log.info(watch.toString());

A more fluent, readable and compact format could be:

StopWatch watch = StopWatch.createStarted();
// Do work
log.info(watch.split().toString());
// Do work
log.info(watch.stop().toString());

@garydgregory
Copy link
Member

-1: This PR breaks binary compatibility. If you really want this, you can create a Jira as a feature request for a future 4.0.

@larshelge
Copy link
Contributor Author

Noted, that is okay @garydgregory .

@garydgregory
Copy link
Member

Closing. Maybe for 4.0, which would be in a different package.

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.

2 participants