The reason is that I just simplified the code to state my case. The
changedImageMethod does some validation (left out for the example) and have
to null-check.

But I agree with Richard though, for the given example that if-statement is
confusing.

Nevertheless calling changedMainImage like this fails equally (without
@Optional Attachment in the interface method declaration), e.g:

Attachment attachment = null;
changedMainImage(attachment);

Dag

2011/3/25 Rickard Öberg <[email protected]>

> Apart from what Ronnie/Arvid said, this seems weird:
>
>
> On 3/24/11 8:16 PM, Dag Blakstad wrote
>
>> public class HasMainImageMixin implements HasMainImage {
>> interface PrivateState {
>> @Optional Association<Attachment> attachment();
>> }
>> @This PrivateState state;
>>
>> public void changedMainImage(Attachment attachment) {
>>         if (attachment == null) {
>>             state.set(null);
>>         }
>>     }
>> }
>>
>
> Shouldn't that be state.attachment().set(null)?
> And why isn't it simply state.attachment().set(attachment)?
>
> /Rickard
>
>
> _______________________________________________
> qi4j-dev mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/qi4j-dev
>
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to