[英]How to create a LinkedHashMap in EMF ecore model?
I am looking for keeping the order of my entries in the map based on the insertion order. 我正在寻找根据插入顺序在地图中保持条目顺序的方法。 So basically I am looking for creating a LinkedHashMap in my ecore model.
所以基本上我正在寻找在我的ecore模型中创建LinkedHashMap的方法。
I need to persist this map, hence I'd like to use the serialization and proxy resolution feature of EMap. 我需要保留此映射,因此我想使用EMap的序列化和代理解析功能。 I tried to cast a LinkedHashMap to EcoreEmap by
((EMap.InternalMapView)myLinkedHashMap).eMap();
我试图通过
((EMap.InternalMapView)myLinkedHashMap).eMap();
将LinkedHashMap投射到EcoreEmap ((EMap.InternalMapView)myLinkedHashMap).eMap();
but that didn't work. 但这没用。
I can think of having a list and map together, and keep the order in list, but I'd really like to avoid duplication of reference, since these two can get out of sync. 我可以考虑使用一个列表并将其映射在一起,并将顺序保持在列表中,但是我真的想避免重复引用,因为这两个可能会不同步。
Do you have any suggestions? 你有什么建议吗?
If we use EMF EMap class, the insertion order will be kept and we wouldn't need a LinkeHashMap. 如果我们使用EMF EMap类,则将保留插入顺序,并且不需要LinkeHashMap。 More details are discussed here:
此处讨论更多详细信息:
http://www.eclipse.org/forums/index.php/mv/tree/451092/1003801/ http://www.eclipse.org/forums/index.php/mv/tree/451092/1003801/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.