From: kkhan Date: Thu, 8 Jun 2006 23:54:44 +0000 (+0000) Subject: Add methods to determine if a CtClass is an annotation or an enum X-Git-Tag: rel_3_17_1_ga~352 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9a1a73334ffa8b3e6b3bff3269cd0b7e95a26726;p=javassist.git Add methods to determine if a CtClass is an annotation or an enum git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@279 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java index 0fbe3438..fe592998 100644 --- a/src/main/javassist/CtClass.java +++ b/src/main/javassist/CtClass.java @@ -433,6 +433,22 @@ public abstract class CtClass { return false; } + /** + * Determines whether this object represents an annotation type. + * It returns true if this object represents an annotation type. + */ + public boolean isAnnotation() { + return false; + } + + /** + * Determines whether this object represents an enum. + * It returns true if this object represents an enum. + */ + public boolean isEnum() { + return false; + } + /** * Returns the modifiers for this class, encoded in an integer. * For decoding, use javassist.Modifier. diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index 372e2b22..1a29269c 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -358,6 +358,14 @@ class CtClassType extends CtClass { return Modifier.isInterface(getModifiers()); } + public boolean isAnnotation() { + return Modifier.isAnnotation(getModifiers()); + } + + public boolean isEnum() { + return Modifier.isEnum(getModifiers()); + } + public int getModifiers() { ClassFile cf = getClassFile2(); int acc = cf.getAccessFlags(); diff --git a/src/main/javassist/Modifier.java b/src/main/javassist/Modifier.java index 7b3cfc79..730e24b6 100644 --- a/src/main/javassist/Modifier.java +++ b/src/main/javassist/Modifier.java @@ -131,6 +131,22 @@ public class Modifier { return (mod & INTERFACE) != 0; } + /** + * Returns true if the modifiers include the annotation + * modifier. + */ + public static boolean isAnnotation(int mod) { + return (mod & ANNOTATION) != 0; + } + + /** + * Returns true if the modifiers include the enum + * modifier. + */ + public static boolean isEnum(int mod) { + return (mod & ENUM) != 0; + } + /** * Returns true if the modifiers include the abstract * modifier.