Motivation
Allow Simple Builders to generate a builder for a Java type that cannot or should not be modified, such as a type from a third-party library.
The original type must remain unchanged.
Proposed API
@SimpleBuilderFor(
value = ExternalUser.class,
options = @SimpleBuilder.Options(
// existing options
)
)
class ExternalBuilders {
}
The new annotation should reuse the existing @SimpleBuilder.Options configuration model instead of duplicating builder options.
Example
Given:
package com.vendor.api;
public class ExternalUser {
public ExternalUser(String name, String email) {
// ...
}
}
The user could declare:
@SimpleBuilderFor(ExternalUser.class)
class ExternalBuilders {
}
and use the generated builder:
ExternalUser user = ExternalUserBuilder.create()
.name("Ada")
.email("ada@example.com")
.build();
Initial Scope
Support externally defined types that can be constructed through accessible Java APIs.
If no suitable construction mechanism is available, fail with a clear compile-time error.
Requirements
• Do not modify the target type.
• Do not require runtime reflection.
• Reuse existing @SimpleBuilder.Options.
• Follow existing builder naming and generation conventions.
• Keep target package selection separate from this feature; see the related package configuration feature.
Further Features
Think of allowing to define multiple classes and it should be possible to call it without options. In this case it should fall back to the compiler default!
Goal
Make Simple Builders useful for generating fluent construction APIs for Java types that the application does not own.
Motivation
Allow Simple Builders to generate a builder for a Java type that cannot or should not be modified, such as a type from a third-party library.
The original type must remain unchanged.
Proposed API
The new annotation should reuse the existing @SimpleBuilder.Options configuration model instead of duplicating builder options.
Example
Given:
The user could declare:
and use the generated builder:
Initial Scope
Support externally defined types that can be constructed through accessible Java APIs.
If no suitable construction mechanism is available, fail with a clear compile-time error.
Requirements
• Do not modify the target type.
• Do not require runtime reflection.
• Reuse existing @SimpleBuilder.Options.
• Follow existing builder naming and generation conventions.
• Keep target package selection separate from this feature; see the related package configuration feature.
Further Features
Think of allowing to define multiple classes and it should be possible to call it without options. In this case it should fall back to the compiler default!
Goal
Make Simple Builders useful for generating fluent construction APIs for Java types that the application does not own.