gittech. site

for different kinds of informations and explorations.

Fbound builder, inheritable and composable Java builder without a FactoryFactory

Published at
3 days ago

FBound

Tools for building better APIs.

The FBound project was created out of writing the FBound Guide to Advanced Fluent APIs, a guide for advanced uses of generic types. This guide was written to explain the generic type patterns and techniques used in creating the Page-Model-Tools web testing framework.

FBound Builder Pattern

The FBound BuilderBase serves as a base class for any Builder type. This pattern allows inheritance, chaining, and re-use of your Builder.

Builder Base class extended by other Builders:
BuilderBase.java

Example User class with Record and Builders:
User.java

Example Facilitator Builder extending User Builder:
Facilitator.java

Example Membership Builder with "guided build mode":
Membership.java

Extension marker interface can only be implemented by a BuilderBase class making it safe to cast to BuilderBase:
Extension.java

ExtensionUtils provides an Extension interface with access to its BuilderBase protected fields:
ExtensionUtils.java

Accept, Apply, Edit extensions which add functional methods to a Builder:
Accept.java, Apply.java, Edit.java

Example Roster Builder implementing Accept, Apply, and Edit extensions:
Roster.java

Example usage of Membership Builder in guided and unguided mode:
Example usage of Roster Builder using other builders and extensions:
BuilderTests.java