java - Checking if an annotation is of a specific type -


I am using reflection to see if any annotation is related to property of a class, a specific Is of type. Currently I am:

  if ("javax.validation.Valid" .equals (annotation.annotationType (). GetName ())) {...}  < / Pre> 

who kills me as a little litter because it depends on a string which is a fully-qualified class-name. If the name space changes in the future, then it can be the cause of subtle errors.

What I would like to do:

  if (class.formname (annotation.notation type). GetName ()) isInstance (new javax.validation.Valid ()) ) {...}  

but javax.validation.Valid is an abstract class and can not be done immediately. Is there a way to simulate the example (or basically use isInstance ) against an interface or an abstract class?

are you looking for just

  (if any If not the comment)  

?


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -