Java Reflection - Modifier

Modifier

Any class or its members have associated modifiers like static, public... These influence the behavior of the code. The Reflection API allows you to query and also modify these modifiers. getModifiers() returns an integer representing all the modifiers associated with the object. This number is composed of different flags related to each kind of modifiers. Instead of complicated binary calculations to extract these values, the Reflection API provides you with methods that help you with this task.
FieldMethodDescription
Modifier.ABSTRACTModifier.isAbstract(int mod)The int value representing the abstract modifier.
Modifier.FINALModifier.isFinal(int mod)The int value representing the final modifier.
Modifier.INTERFACEModifier.isInterface(int mod)The int value representing the interface modifier.
Modifier.NATIVEModifier.isNative(int mod)The int value representing the native modifier.
Modifier.PRIVATEModifier.isPrivate(int mod)The int value representing the private modifier.
Modifier.PROTECTEDModifier.isProtected(int mod)The int value representing the protected modifier.
Modifier.PUBLICModifier.isPublic(int mod)The int value representing the public modifier.
Modifier.STATICModifier.isStatic(int mod)The int value representing the static modifier.
Modifier.STRICTModifier.isStrict(int mod)The int value representing the strictfp modifier.
Modifier.SYNCHRONIZEDModifier.isSynchronized(int mod)The int value representing the synchronized modifier.
Modifier.TRANSIENTModifier.isTransient(int mod)The int value representing the transient modifier.
Modifier.VOLATILEModifier.isVolatile(int mod)The int value representing the volatile modifier.
Additionally it provides a method toString(int mod), that returns a string describing the access modifier flags in the specified modifier.