Yeah - the big problem is that this generates a warning:
Arrays.asList( WarmUp.class, PostConstruct.class )
I'm glad that this is fixed in Java 7. BTW - why are we targeting Java 5? Can
we at least move to Java 6?
-JZ
On Mar 13, 2013, at 7:54 PM, Mikhail Mazursky <[email protected]>
wrote:
> Hi Simone.
>
> I little inconvenience with varargs is that it will produce warnings is
> user code because we use parametrized type Class<? extends Annotation> in
> it (see [1]). The correct solution would be to use @SafeVarargs [2] but it
> was only added in Java 7 and we target Java 5. So i think we better keep
> current constructor intact. When i mentioned asList() i was talking about
> internal use of it in Onami code instead of ListBuilder.
>
> Also Onami user can use asList() himself and it is annotated with
> @SafeVarargs in Java 7+ so no warnings in this case.
>
> WDYT?
>
> [1]: http://stackoverflow.com/questions/4257883/warning-for-generic-varargs
> [2]: http://docs.oracle.com/javase/7/docs/api/java/lang/SafeVarargs.html
>
> 2013/3/14 Simone Tripodi <[email protected]>
>
>> Hi Mikhail!
>>
>> +1 for varargs, result would look charming like a sunshine:
>>
>> public AbstractLifeCycleModule( Class<? extends
>> Annotation>...annotationTypes )
>> {
>> this( any(), asList( annotationTypes ) );
>> }
>>
>> Of course I'd change the overloading constructor as well:
>>
>> public AbstractLifeCycleModule( Matcher<? super TypeLiteral<?>>
>> typeMatcher, Class<? extends Annotation>...annotationTypes )
>> {
>> this( Arrays.asList( annotationTypes ), typeMatcher );
>> }
>>
>> Clean, compact, clear, direct. We cannot ask more :)
>> Feel free to fill an issue and provide a fix.
>>
>> my 2 cents,
>> -Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://simonetripodi.livejournal.com/
>> http://twitter.com/simonetripodi
>> http://www.99soft.org/
>>
>>
>> On Wed, Mar 13, 2013 at 1:15 PM, Mikhail Mazursky
>> <[email protected]> wrote:
>>> Hi Simone, Jordan.
>>>
>>> IMHO AbstractLifeCycleModule should check that the List that was passed
>> to
>>> it contains no duplicates and throw exception if it does. In any case
>>> behaviour in such situation should be described it JavaDocs.
>>> Also, is this ListBuilder need to be public API at all? And maybe get rid
>>> of it completely by using Arrays.asList()?
>>>
>>> 2013/3/12 Simone Tripodi <[email protected]>
>>>
>>>> Hi Jordan,
>>>>
>>>>>> * the adapted List of annotation should be IMHO a LinkedHashSet,
>>>>>> otherwise users could specify the same type twice in the list and
>>>>>> drive the lifecycle engine to invoke twice the same method in
>>>>>> different phases - IIUC this is not the desired behaviour, or is it?
>>>>> It's a List because it needs to be ordered. I hadn't thought about
>>>> duplicates.
>>>>
>>>> the LinkedHashSet[1] will preserve the order like the List does,
>>>> moreover will keep the unicity of its elements.
>>>>
>>>>
>>