Enum Modifier
- java.lang.Object
-
- java.lang.Enum<Modifier>
-
- com.tonic.analysis.source.ast.decl.Modifier
-
- All Implemented Interfaces:
Serializable,Comparable<Modifier>
public enum Modifier extends Enum<Modifier>
A Java source modifier keyword, paired with the keyword text it prints as.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ABSTRACTAccess flag0x0400, declaring a class or method with no body of its own.DEFAULTA default interface method body; source-only, with no access flag bit, so decoding flags never yields it.FINALAccess flag0x0010, forbidding reassignment, overriding or subclassing depending on what it is applied to.NATIVEAccess flag0x0100, marking a method implemented outside the class file.PRIVATEAccess flag0x0002, visible only within the declaring class.PROTECTEDAccess flag0x0004, visible to the package and to subclasses.PUBLICAccess flag0x0001, visible everywhere; prints first because declaration order is print order.STATICAccess flag0x0008, bound to the class rather than an instance.STRICTFPAccess flag0x0800, pinning floating point to strict IEEE 754 semantics.SYNCHRONIZEDAccess flag0x0020on a method, taking the receiver's monitor for the duration of the call.TRANSIENTAccess flag0x0080on a field, excluding it from default serialization.VOLATILEAccess flag0x0040on a field, forcing every access to reach main memory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Set<Modifier>fromAccessFlags(int flags)Decodes class file access flags into modifiers; DEFAULT has no flag bit and is never produced.StringgetKeyword()booleanisAccessModifier()static StringtoSourceString(Set<Modifier> modifiers)Joins modifiers with spaces in declaration order, regardless of the set's own order.static ModifiervalueOf(String name)Returns the enum constant of this type with the specified name.static Modifier[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
PUBLIC
public static final Modifier PUBLIC
Access flag0x0001, visible everywhere; prints first because declaration order is print order.
-
PROTECTED
public static final Modifier PROTECTED
Access flag0x0004, visible to the package and to subclasses.
-
PRIVATE
public static final Modifier PRIVATE
Access flag0x0002, visible only within the declaring class.
-
STATIC
public static final Modifier STATIC
Access flag0x0008, bound to the class rather than an instance.
-
FINAL
public static final Modifier FINAL
Access flag0x0010, forbidding reassignment, overriding or subclassing depending on what it is applied to.
-
ABSTRACT
public static final Modifier ABSTRACT
Access flag0x0400, declaring a class or method with no body of its own.
-
SYNCHRONIZED
public static final Modifier SYNCHRONIZED
Access flag0x0020on a method, taking the receiver's monitor for the duration of the call.
-
NATIVE
public static final Modifier NATIVE
Access flag0x0100, marking a method implemented outside the class file.
-
STRICTFP
public static final Modifier STRICTFP
Access flag0x0800, pinning floating point to strict IEEE 754 semantics.
-
TRANSIENT
public static final Modifier TRANSIENT
Access flag0x0080on a field, excluding it from default serialization.
-
VOLATILE
public static final Modifier VOLATILE
Access flag0x0040on a field, forcing every access to reach main memory.
-
DEFAULT
public static final Modifier DEFAULT
A default interface method body; source-only, with no access flag bit, so decoding flags never yields it.
-
-
Method Detail
-
values
public static Modifier[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Modifier c : Modifier.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Modifier valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getKeyword
public String getKeyword()
- Returns:
- the keyword
-
fromAccessFlags
public static Set<Modifier> fromAccessFlags(int flags)
Decodes class file access flags into modifiers; DEFAULT has no flag bit and is never produced.- Parameters:
flags- the access flag bits- Returns:
- the modifiers the bits set
-
toSourceString
public static String toSourceString(Set<Modifier> modifiers)
Joins modifiers with spaces in declaration order, regardless of the set's own order.- Parameters:
modifiers- the modifiers to print- Returns:
- the keyword text, empty if there are none
-
isAccessModifier
public boolean isAccessModifier()
- Returns:
- whether this is public, protected or private
-
-