0

I want to return a list of elements of 'ListOfObjects' that are being referenced by 'SomeOtherObject' with it's(SomeOtherObject's) attribute satisfying the condition. I'm trying this code:

ParentObj.ListOfObjects.select(e|e.referencingContainers.typeSelect(SomOtherObject).attr.isValid());

'ListOfObjects' extracts a list of particular objects from the 'ParentObj'.But the above code gives me nothing. Please help me out in figuring out what's wrong here.

Sujju
  • 97
  • 8

2 Answers2

0

It's because, in the above piece of code, the result of the expression inside the select returns a list and not an a boolean. To make it boolean I'd have to rewrite the code this way:

ParentObj.ListOfObjects.select(e|e.referencingContainers.typeSelect(SomOtherObject).select(el|el.attr.isValid()).size > 0);

The select inside the select along with the check for size is what made the difference there.

Sujju
  • 97
  • 8
  • Or instead of doing `select(el|el.attr.isValid()).size > 0)` `exists(el|el.attr.isValid())` can also be done. – Sujju Jan 30 '15 at 11:16
0

There is an extension to find objects that reference a specific object: org::eclipse::xtend::util::stdlib::crossref

You can also specify conditions in the same way. Here is more information about Cross References Extensions.

user3399000
  • 353
  • 3
  • 18