|Reflective access to generated classes [message #1691632]
||Wed, 08 April 2015 16:06
| Alexander Klatt
Registered: April 2014
I am struggling with reflective access to the fields of my generated classes.
So this works for me in one model but not in the other:
ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(EPackage.Registry.INSTANCE);
List<EStructuralFeature> allContent = extendedMetaData.getAllElements(testObject.eClass())
I am not able to track the difference between the model which works and the one
which does not. Does anyone know how to enable this reflective access?
[Updated on: Wed, 08 April 2015 16:09]
Report message to a moderator
|Re: Reflective acces to generated classes [message #1691683 is a reply to message #1691638]
||Thu, 09 April 2015 04:22
| Ed Merks
Registered: July 2009
You can manually create extended metadata annotations for an Ecore
model. But I'm not sure your goal. Why not use
testObject.eClass().getEAllStructuralFeatures()? What are you hoping to
achieve knowing about elements versus attributes in the XML
serialization? You might use
ExtendedMetaData.getFeatureKind(EStructuralFeature) to determine for
your goal, but without knowing what you're trying to achieve, it's hard
to give advice. For example, a cross reference might be serialized as
attribute or as an element, depending on what options are passed to the
resource implementation, e.g.,
just looking at the model seems unhelpful...
On 08/04/2015 6:34 PM, Alexander Klatt wrote:
> Okay thanks, this makes sense. I was only looking at the property view...
> The model which worked, was created from an xsd schema. So the
> annotations were created automatically.
> Is there any other way to get reflective access for manually created
> ecore models?
Powered by FUDForum
. Page generated in 0.01974 seconds