Feature Request
Inspired by RecordBuilder's field getter pattern, where the builder exposes accessor methods to read back the current state of each field during construction.
Current State
The TrackedValue infrastructure already has .isSet() and .value() methods, but these are only used internally (in build(), collection add, etc.). There are no public getters on the builder to read field values from outside.
Proposed Feature
Add an optional annotation flag generateFieldGetters = true to @SimpleBuilder / @SimpleMinimalBuilder that generates two methods per field:
// Check if a field was explicitly setpublicbooleanisSetAccreditationName() {
returnthis.accreditationName.isSet();
}
// Read the current value (null if unset)publicStringaccreditationName() {
returnthis.accreditationName.value();
}Use Cases
- Conditional logic during building:
if (builder.accreditationName() == null) builder.accreditationName("UNKNOWN"); - Check if explicitly set:
if (!builder.isSetAccreditationName()) { /* only set default if user didn't */ } - Debugging: Inspect builder state mid-construction
- Validation: Read value, validate, optionally override before build
Why Optional?
Adding getters increases the builder's API surface. Users who want a minimal builder (like @SimpleMinimalBuilder) may not want these methods. Making it opt-in via a flag keeps the default behavior unchanged.
Implementation Notes
- Delegates to existing
TrackedValue.isSet() and TrackedValue.value() — minimal implementation effort - Should be a new generator or enhancer with a configurable priority
- Consider naming:
isSetXxx() vs hasXxx() — isSet is consistent with TrackedValue terminology
Feature Request
Inspired by RecordBuilder's field getter pattern, where the builder exposes accessor methods to read back the current state of each field during construction.
Current State
The
TrackedValueinfrastructure already has.isSet()and.value()methods, but these are only used internally (inbuild(), collection add, etc.). There are no public getters on the builder to read field values from outside.Proposed Feature
Add an optional annotation flag
generateFieldGetters = trueto@SimpleBuilder/@SimpleMinimalBuilderthat generates two methods per field:Use Cases
if (builder.accreditationName() == null) builder.accreditationName("UNKNOWN");if (!builder.isSetAccreditationName()) { /* only set default if user didn't */ }Why Optional?
Adding getters increases the builder's API surface. Users who want a minimal builder (like
@SimpleMinimalBuilder) may not want these methods. Making it opt-in via a flag keeps the default behavior unchanged.Implementation Notes
TrackedValue.isSet()andTrackedValue.value()— minimal implementation effortisSetXxx()vshasXxx()—isSetis consistent withTrackedValueterminology