Fluent APIs Are More Than Just Chaining

A common characteristic of fluent APIs is the use of method chaining: allowing calls to be strung together in a single statement without storing intermediate results. The simplest way to support chaining is to have each method return this . However, doing so can leave the object in an inconsistent or invalid state—especially when methods are called out of order. By narrowing or changing the return…