Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Duplicate elements in ELists(Questions about how ELists work)
Duplicate elements in ELists [message #1836702] Tue, 12 January 2021 14:42 Go to next message
Jonathan Eugenio is currently offline Jonathan EugenioFriend
Messages: 11
Registered: March 2020
Junior Member
Hello all,

I had some questions about ELists. Can they not have duplicate elements, and is there some way to circumvent this? I noticed this while utilizing the API for my grammar. In some cases, ELists may have duplicate items and in others they cannot accept duplicate items. Is there more information on how ELists work with duplicate elements? Thank you
Re: Duplicate elements in ELists [message #1836703 is a reply to message #1836702] Tue, 12 January 2021 14:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Quote:
Can they not have duplicate elements,


I suspect a confused negative.

The isUnique() API controls unique/not-unique.

If you use an Ecore model you will find that many-element collections have a unique and an ordered option. Explore Ecore to learn how the underlying capabilities work.

Regards

Ed Willink
Re: Duplicate elements in ELists [message #1836704 is a reply to message #1836702] Tue, 12 January 2021 15:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi, this depends on the type and place you use the EList
and what
value e.g org.eclipse.emf.common.util.AbstractEList.isUnique() has.
you may play around with a manual metamodel



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Duplicate elements in ELists [message #1836770 is a reply to message #1836704] Wed, 13 January 2021 14:44 Go to previous messageGo to next message
Jonathan Eugenio is currently offline Jonathan EugenioFriend
Messages: 11
Registered: March 2020
Junior Member
Thanks for the feedback. In my meta-model, isUnique() was already set to false for the object in question.
I was able to solve the issue by using myElist.addUnique(EObject) instead of myElist.add(EObject). I appreciate
the help.
Re: Duplicate elements in ELists [message #1836777 is a reply to message #1836770] Wed, 13 January 2021 18:24 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This sounds very wrong. I have been using EMF for many years and AFAICR I have never needed to use addUnique(); add() works fine. In so far as it doesn't I suspect that you have a much more deep seated problem waiting to bite you when it can occur in a more obscure and intermittent fashion.

I don't think it's your problem but perhaps you should be aware of: https://bugs.eclipse.org/bugs/show_bug.cgi?id=89325

Regards

Ed Willink
Previous Topic:Retrieve index without having to load resources in standalone context?
Next Topic:Xtend: Any way to show javadoc of super-method in hover?
Goto Forum:
  


Current Time: Sat Apr 20 04:29:49 GMT 2024

Powered by FUDForum. Page generated in 0.03213 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top