
gittech. site
for different kinds of informations and explorations.
Fbound builder, inheritable and composable Java builder without a FactoryFactory
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 withRecord
andBuilders
:
User.java
Example
Facilitator Builder
extendingUser Builder
:
Facilitator.java
Example
Membership Builder
with "guided build mode":
Membership.java
Extension
marker interface can only be implemented by aBuilderBase
class making it safe to cast toBuilderBase
:
Extension.java
ExtensionUtils
provides anExtension
interface with access to itsBuilderBase
protected fields:
ExtensionUtils.java
Accept
,Apply
,Edit
extensions which add functional methods to a Builder:
Accept.java, Apply.java, Edit.java
Example
Roster Builder
implementingAccept
,Apply
, andEdit
extensions:
Roster.java
Example usage of
Membership Builder
in guided and unguided mode:
Example usage ofRoster Builder
using other builders and extensions:
BuilderTests.java