|
|
|
|
Re: Use getEStructuralFeatures or getAllEStructuralFeatures? [message #1787256 is a reply to message #1787247] |
Tue, 22 May 2018 19:43 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Yes, I don't believe the claim either. The org.eclipse.emf.ecore.EClass.getEStructuralFeature(String) method is implemented like this in EClassImpl: public EStructuralFeature getEStructuralFeature(String name)
{
getFeatureCount();
if (eNameToFeatureMap == null)
{
Map<String, EStructuralFeature> result = new HashMap<String, EStructuralFeature>(3 * eAllStructuralFeatures.size() / 2 + 1);
for (EStructuralFeature eStructuralFeature : eAllStructuralFeatures)
{
String key = eStructuralFeature.getName();
EStructuralFeature duplicate = result.put(key, eStructuralFeature);
if (duplicate != null)
{
result.put(key, duplicate);
}
}
eNameToFeatureMap = result;
}
return eNameToFeatureMap.get(name);
} So is implemented to create a map from the contents that are returned by getEAllStructuralFeatures(). Of course model.eClass().getEStructuralFeatures().stream().filter(x -> x instanceof PackagedElement) will definitely be an empty list because no EStructuralFeature will ever be an instance of PackageElement. Likely model.eContents().stream().filter(x -> x instanceof PackagedElement) makes more sense.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.05168 seconds