Enum Modifier

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ABSTRACT
      Access flag 0x0400, declaring a class or method with no body of its own.
      DEFAULT
      A default interface method body; source-only, with no access flag bit, so decoding flags never yields it.
      FINAL
      Access flag 0x0010, forbidding reassignment, overriding or subclassing depending on what it is applied to.
      NATIVE
      Access flag 0x0100, marking a method implemented outside the class file.
      PRIVATE
      Access flag 0x0002, visible only within the declaring class.
      PROTECTED
      Access flag 0x0004, visible to the package and to subclasses.
      PUBLIC
      Access flag 0x0001, visible everywhere; prints first because declaration order is print order.
      STATIC
      Access flag 0x0008, bound to the class rather than an instance.
      STRICTFP
      Access flag 0x0800, pinning floating point to strict IEEE 754 semantics.
      SYNCHRONIZED
      Access flag 0x0020 on a method, taking the receiver's monitor for the duration of the call.
      TRANSIENT
      Access flag 0x0080 on a field, excluding it from default serialization.
      VOLATILE
      Access flag 0x0040 on a field, forcing every access to reach main memory.
    • Enum Constant Detail

      • PUBLIC

        public static final Modifier PUBLIC
        Access flag 0x0001, visible everywhere; prints first because declaration order is print order.
      • PROTECTED

        public static final Modifier PROTECTED
        Access flag 0x0004, visible to the package and to subclasses.
      • PRIVATE

        public static final Modifier PRIVATE
        Access flag 0x0002, visible only within the declaring class.
      • STATIC

        public static final Modifier STATIC
        Access flag 0x0008, bound to the class rather than an instance.
      • FINAL

        public static final Modifier FINAL
        Access flag 0x0010, forbidding reassignment, overriding or subclassing depending on what it is applied to.
      • ABSTRACT

        public static final Modifier ABSTRACT
        Access flag 0x0400, declaring a class or method with no body of its own.
      • SYNCHRONIZED

        public static final Modifier SYNCHRONIZED
        Access flag 0x0020 on a method, taking the receiver's monitor for the duration of the call.
      • NATIVE

        public static final Modifier NATIVE
        Access flag 0x0100, marking a method implemented outside the class file.
      • STRICTFP

        public static final Modifier STRICTFP
        Access flag 0x0800, pinning floating point to strict IEEE 754 semantics.
      • TRANSIENT

        public static final Modifier TRANSIENT
        Access flag 0x0080 on a field, excluding it from default serialization.
      • VOLATILE

        public static final Modifier VOLATILE
        Access flag 0x0040 on 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 name
        NullPointerException - 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