|
|
Re: [Acceleo] How to test for empty/null reference? [message #639611 is a reply to message #639588] |
Wed, 17 November 2010 07:59 |
|
This is a multi-part message in MIME format.
--------------090905000309020208070602
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Jeff,
This will work well if you set it to be 0..* because EMF will never
return "null" in such cases : it is a collection, whether it is empty or
not. In the case of "0..1" multiplicity, you have either "null" or an
object.
The problem you have is that you tried to do a "for" loop on such a 0..1
reference. Acceleo accepts "for" on an object which is not a Collection
(it will simply iterate once), but it will refuse iterating on an Object
which is either "null" or "invalid"... which is what you get, and will
not be changed.
I don't understand why you are using a "for" loop at this point. If the
reference is 0..1, you either have something or not. Why not use an "if"?
[for (anActivity : Activity | myActivities.activities)]
[if (not anActivity.oclIsUndefined())]
Laurent Goubet
Obeo
On 17/11/2010 05:08, glenviewjeff wrote:
> Update: I noticed that if I change the Activity to contain 0..* menus
> then the for loops work fine. But I want to limit there to be only 0 or
> 1 menus. Is this an Acceleo bug or am I misunderstanding something?
--------------090905000309020208070602
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------090905000309020208070602--
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03971 seconds