IMHO, this "chaining" approach is not used, as a rule, in Java, except when builders or things are essentially builders.
What you describe here is actually a calculator calculator.
You should probably have the CalculatorBuilder class that you create, install a few things (for example, useAbs, checkArguments, etc.) and ultimately call it "build". Build will return a calculator that does not know anything about how it was created, except for the state in which it was initialized.
In addition, I personally do not like the design that mixes the builder style logic (for example, "useAbs") and everything that affects the state of the underlying object (for example, checkArguments). I would say choose one. Either generate a default calculator, or install it later, or create everything to create everything, and then create instances whose functionality and behavior cannot be changed.
Uri
source share