I had an idea to use a Dao class (Dao.java):
class Dao <Model extends AbstractModel> {
public String getUrl() {
return Model.class.getAnnotation(MyPath.class).url();
}
}
and a model like this (Account.java):
@MyPath(url = "blabla")
class Account extends AbstractModel {
...
}
but the problem is that in that case if i run
@Test
public void testDaoUrl() {
Dao<Account> dao = new Dao<Account>();
dao.getUrl();
}
Model.class seems to be an AbstractModel and not an Account. Is there any work around to get MyPath annotation from the Dao (without giving it an instance of Account.class)?
Thanks in advance for any idea!
PS: MyPath-Annotation:
@Retention(RUNTIME)
@Target(TYPE)
@interface MyPath {
public String url();
}