mardi 16 mai 2017

Is it possible to represent a Class as a Field?

I need to retrieve annotation inside a class. Imagine this:

@MyAnnotation(MyClass.class)
public Table myTable;

What I need to do is to initialize a variable inside class Table from a class inside the annotation. The question is, how can I represent Table class as a field in order to retrieve a value from annotation like this:

Field tableField = ? // Here I should somehow cast 'this' to type Field
Class annotationValue = tableField.getAnnotation(MyAnnotation.class).value();

Is it possible to cast a Table class into a Field class somehow?





Aucun commentaire:

Enregistrer un commentaire