logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <rgo...@apache.org>
Subject Re: PluginAttribute#defaultEnum()?
Date Sun, 01 Jun 2014 00:38:46 GMT
Gary, I know you said you didn't like 

@PluginAttribute(name="foo", defaultValue="1") int foo

But after looking at http://maven.apache.org/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Parameter.html
I am wondering if that isn't the best way to go. Doing that would allow the default value
to be something like ${sys:fooDefault} which you can't do with strong typing.

Ralph

Sent from my iPad

> On May 31, 2014, at 4:25 PM, Ralph Goers <rgoers@apache.org> wrote:
> 
> Why wouldn't you do
> 
> @PluginAttributeInt(value="foo", defaultValue=1) int foo
> 
> ?
> 
> That said, I'm really not crazy about this. I wish you could do
> 
> @PluginAttribute<Integer>(value="foo", defaultValue=1) int foo
> 
> Ralph
> 
> Sent from my iPad
> 
>> On May 31, 2014, at 12:50 PM, Gary Gregory <garydgregory@gmail.com> wrote:
>> 
>> So the bummer is that this redundant with the arg type in the signature:
>> 
>> @PluginAttributeInt (value="foo", defaultInt=1) int foo
>> 
>> We should also pick up the attribute name by reflection if it is missing from the
annotation.
>> 
>> But you'd only need it to spec a default value.  So could we keep PluginAttribute
with only a value and then have an annotation for each default value type? @DefaultInt and
so on..?
>> 
>> Ideally:
>> 
>> @PluginAttribute() @DefaultInt (1) int foo
>> 
>> Thoughts? 
>> 
>> Gary
>> 
>> 
>> -------- Original message --------
>> From: Paul Benedict
>> Date:05/30/2014 22:15 (GMT-05:00)
>> To: Apache Log4J Developers
>> Subject: Re: PluginAttribute#defaultEnum()?
>> 
>> Totally cleaner.
>> 
>>> On May 30, 2014 8:58 PM, "Gary Gregory" <garydgregory@gmail.com> wrote:
>>>> On Fri, May 30, 2014 at 9:39 PM, Paul Benedict <pbenedict@apache.org>
wrote:
>>>> I think you guys are better off doing separate annotations to do strong typing.
You could use a stereotyping pattern like Bean Validation spec.
>>>> 
>>>> public @interface PluginAttribute ...
>>>> 
>>>> Then annotate other annotations with that:
>>>> @PluginAttribute
>>>> public @interface IntPluginAttribute
>>>> 
>>> 
>>> I did propose that earlier ;-) It seems much cleaner...
>>> 
>>> Gary
>>>  
>>>> See how the Been Validation spec works to copy their pattern.
>>>> 
>>>>> On May 30, 2014 7:55 PM, "Gary Gregory" <garydgregory@gmail.com>
wrote:
>>>>> Hm... you cannot use Enum in the return type for an annotation attribute,
only an actual enum, like RetentionPolicy. So it seems a no-go.
>>>>> 
>>>>> Gary
>>>>> 
>>>>> 
>>>>>> On Fri, May 30, 2014 at 4:24 PM, Matt Sicker <boards@gmail.com>
wrote:
>>>>>> I had the same hold-up when thinking about adding that, too. How
about RetentionPolicy.SOURCE? Or ElementType.TYPE? Something annotation-related like that.
>>>>>> 
>>>>>> 
>>>>>>> On 30 May 2014 13:12, Gary Gregory <garydgregory@gmail.com>
wrote:
>>>>>>> I added PluginAttribute#defaultClass() since we can have a Class
has an attribute value.
>>>>>>> 
>>>>>>> One can also have an Enum as an attribute value, but what default
should be use?
>>>>>>> 
>>>>>>> Gary
>>>>>>> 
>>>>>>> -- 
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>> JUnit in Action, Second Edition
>>>>>>> Spring Batch in Action
>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>> Home: http://garygregory.com/
>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>> Matt Sicker <boards@gmail.com>
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> JUnit in Action, Second Edition
>>>>> Spring Batch in Action
>>>>> 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
>>> JUnit in Action, Second Edition
>>> Spring Batch in Action
>>> Blog: http://garygregory.wordpress.com 
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory

Mime
View raw message