How can I save generic Type information in xcore model?

50 views Asked by At

I would like to have a model that contains a name and object type. The type could be any object type, not necessarily restricted to other models, so I don't want to use EDataType for this. How can I do this?

Basically something like this:

class GenericParameter
{
    /*
     * The data type of the parameter
     */
    Type datatype

    /*
     * Parameter name
     */     
    String name
}

I can't seem to import this from java.lang.reflect. The resulting error is: "Type cannot be resolved to a type." The intent is to store meta information about permissible parameters in a larger system. I could just use a straight up generic Object but I feel like that's cheating, especially since I don't care about any specific object itself anyway, just the type.

1

There are 1 answers

0
Joe On

Classy hacking question you ask

public <E extends Object> void set(E ref);

public <E extends Object> E get();

If you're trying to derive the code somehow, your best bet is to get the name of the class, and use reflection to load the class name instances, if the reference is not found, you don't have the library you're attempting to reference in the JVM you are attempting to do so in.