This code can check whether a class is deprecated or not
@Deprecated
public class
RetentionPolicyExample
{
public static void main(String[] args){
boolean isDeprecated=false;
if(RetentionPolicyExample.class.getAnnotations().length>0){
isDeprecated= RetentionPolicyExample.class
.getAnnotations()[0].toString()
.contains("Deprecated");
}
System.out.println("is deprecated:"+ isDeprecated);
}
}
But, how can be checked if any variable is annotated as deprecated?
@Deprecated
String
variable;
Aucun commentaire:
Enregistrer un commentaire