... and yes the code state.set(null); is plain wrong. My bad, that uses code with flaws as example.
Dag 2011/3/25 Dag Blakstad <[email protected]> > 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 >> > > > > > -- ------------------------------------ Dag Blakstad http://no.linkedin.com/in/dagblakstad http://webstep.no/ansatte/dag-blakstad/ Senior Konsulent Webstep AS Mobil : +47 95 22 69 22 Lysaker Torg 2, 1366 Oslo Pb 66, 1324 Lysaker http://www.webstep.no Oslo - Bergen - Stavanger - Trondheim ------------------------------------
_______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

