You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/08/10 00:34:20 UTC
[jira] [Created] (LOG4J2-1507) Allow Builders to be completely
generic
Gary Gregory created LOG4J2-1507:
------------------------------------
Summary: Allow Builders to be completely generic
Key: LOG4J2-1507
URL: https://issues.apache.org/jira/browse/LOG4J2-1507
Project: Log4j 2
Issue Type: New Feature
Components: Configurators
Reporter: Gary Gregory
Assignee: Gary Gregory
Fix For: 2.7
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}}.
{code:java}
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);
}
}
{code}
(I have a patch for this)
(The next step (and ticket) will be to allow to use a Builder that extends another Builder.)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org