Fluent Method

Behavior DefinED

The PED advocacy of the Fluent Method idiom brings programming flexibility to a code base. That is, both production source and JUnit test code can employ the same semantic to drive enhanced readability.

Note: The JUnit RuleChain and the AssertJ assertThat() methods incorporate the Fluent Rule and Fluent Assert approach (respectively) into their testing frameworks.

Structural Elements

Here is a Fluent Rule example from a test class using a JUnit RuleChain: 


Here is a query Parameter Object example using a Fluent Setter from EclipseLink source code:

JPA Fluent Method

Here is an example of an abstract base class Fluent Setter implementation with a generic method. This implementation ensures that use of a concrete subclass does not require a cast:

Base Class Fluent Method

Source Code Search