Details
-
New Feature
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Allow Builders to be completely generic. This is not just supporting Builder<T>, which works in 2.6.2, but to allow declarations like Builder<B extends Builder<B>> combined with setters that return B.
public static class Builder<B extends Builder<B>> implements org.apache.logging.log4j.core.util.Builder<ValidatingPluginWithGenericBuilder> { @PluginBuilderAttribute @Required(message = "The name given by the builder is null") private String name; public B withName(final String name) { this.name = name; return asBuilder(); } @SuppressWarnings("unchecked") private B asBuilder() { return (B) this; } @Override public ValidatingPluginWithGenericBuilder build() { return new ValidatingPluginWithGenericBuilder(name); } }
(I have a patch for this)
(The next step (and ticket) will be to allow to use a Builder that extends another Builder.)
Attachments
Issue Links
- is required by
-
LOG4J2-1508 Allow a Builder to subclass another Builder
-
- Resolved
-