Get the Annotations of Enum Fields

My question is how to get the Annotations used?

I have already tried it this way without success.

What do I do wrong?
One more note, the Java classes are all in the same solution.

 

Thanks already in advance

3 comments

Try getEnumConstants() instead of getFields(). This is not MPS-specific, by the way, it's just Java reflection.

0

Actually, scratch that. Your code is correct, but the annotations themselves need to be annotated with @Retention(RetentionPolicy.RUNTIME)

0

Sergej is certainly correct, but it seems there is a more "MPS" way to do this, that isn't an enum-with-annotations.

I would think about structuring the project this way:

concept MeasurementType extends BaseConcept
implements IValidIdentifier
...

children:
valueType: Type[1]

concept MeasurementTypes
...

children:
types: MeasurementType[0..n]

Then depending on where you need that information, you could create a template that creates an enum from those concepts, or create a subconcept of Type which references a MeasurementType, and replaces itself with the valueType.  

0

Please sign in to leave a comment.