logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: PluginAttribute vs. IntPluginAttribute
Date Mon, 26 May 2014 13:34:16 GMT
On Mon, May 26, 2014 at 9:02 AM, Remko Popma <remko.popma@gmail.com> wrote:

>
>
>
> On Mon, May 26, 2014 at 9:58 PM, Gary Gregory <garydgregory@gmail.com>wrote:
>
>> A recent commit contains:
>>
>>
>>> +            @PluginAttribute(value = "blocking", defaultValue = "true")
>>> final boolean blocking,
>>>
>>
>> Using a String default for a non-string attribute seems like a punch in
>> the eye ;-) This really feels unnatural.
>>
>> Currently, I cannot say:
>>
>> @PluginAttribute(value = "blocking", defaultValue = true) final boolean
>> blocking,
>> @PluginAttribute(value = "someInt", defaultValue = 123) final int
>> blocking,
>>
>> That would require the annotation attribute's defaultValue to be typed as
>> an Object which is illegal.
>>
>
> Would it be an idea to have different attributes for the default value,
> one for each type?
> @PluginAttribute(value = "blocking", defaultBooleanValue = true) final
> boolean blocking,
> @PluginAttribute(value = "someInt", defaultIntValue = 123) final int
> blocking,
>
>

I do not think so. What would this mean:

@PluginAttribute(value = "foo", defaultIntValue = 123, defaultBooleanValue
= true) final int blocking,

?

Gary


>> I suggest:
>>
>> @BooleanPluginAttribute(value = "someBool", defaultValue = true) final
>> boolean blocking
>> @IntPluginAttribute(value = "someInt", defaultValue = 123) final int
>> blocking
>>
>> If not, then at least say:
>>
>> @PluginAttribute(value = "blocking", defaultValue = TRUE)
>>
>> and do a static import of TRUE from our Strings class (assuming you'd add
>> TRUE to Strings).
>>
>> If we are going to do typed configuration with a custom annotation
>> mechanism it seems inevitable to have to go with IntPluginAttribute, and so
>> on. Using mixed types looks very odd.
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message