Enum Class XAccessFlag

java.lang.Object
java.lang.Enum<XAccessFlag>
com.cryptomorin.xseries.reflection.XAccessFlag
All Implemented Interfaces:
Serializable, Comparable<XAccessFlag>, Constable

@Experimental public enum XAccessFlag extends Enum<XAccessFlag>
This class is similar to Oracle's AccessFlag default implementation which only exists on Java 20+ It also aims to add a few new APIs such as isSet(int) and isSet(int, XAccessFlag...)
Since:
12.0.0
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    A location within a class file where flags can be applied.

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The access flag ACC_ABSTRACT, corresponding to the source modifier abstract, with a mask value of "0x%04x" Modifier#ABSTRACT.
    The access flag ACC_ANNOTATION with a mask value of "0x%04x" Modifier#ANNOTATION.
    The access flag ACC_BRIDGE with a mask value of "0x%04x" Modifier#BRIDGE
    The access flag ACC_ENUM with a mask value of "0x%04x" Modifier#ENUM.
    The access flag ACC_FINAL, corresponding to the source modifier final, with a mask value of "0x%04x" Modifier#FINAL.
    The access flag ACC_INTERFACE with a mask value of 0x0200.
    The access flag ACC_MANDATED with a mask value of "0x%04x" Modifier#MANDATED.
    The access flag ACC_MODULE with a mask value of 0x8000.
    The access flag ACC_NATIVE, corresponding to the source modifier native, with a mask value of "0x%04x" Modifier#NATIVE.
    The module flag ACC_OPEN with a mask value of 0x0020.
    The access flag ACC_PRIVATE, corresponding to the source modifier private, with a mask value of "0x%04x" Modifier#PRIVATE.
    The access flag ACC_PROTECTED, corresponding to the source modifier protected, with a mask value of "0x%04x" Modifier#PROTECTED.
    The access flag ACC_PUBLIC, corresponding to the source modifier public, with a mask value of "0x%04x" Modifier#PUBLIC.
    The access flag ACC_STATIC, corresponding to the source modifier static, with a mask value of "0x%04x" Modifier#STATIC.
    The module requires flag ACC_STATIC_PHASE with a mask value of 0x0040.
    The access flag ACC_STRICT, corresponding to the source modifier strictfp, with a mask value of "0x%04x" Modifier#STRICT.
    The access flag ACC_SUPER with a mask value of 0x0020.
    The access flag ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of "0x%04x" Modifier#SYNCHRONIZED.
    The access flag ACC_SYNTHETIC with a mask value of "0x%04x" Modifier#SYNTHETIC.
    The access flag ACC_TRANSIENT, corresponding to the source modifier transient, with a mask value of "0x%04x" Modifier#TRANSIENT.
    The module requires flag ACC_TRANSITIVE with a mask value of 0x0020.
    The access flag ACC_VARARGS with a mask value of "0x%04x" Modifier#VARARGS.
    The access flag ACC_VOLATILE, corresponding to the source modifier volatile, with a mask value of "0x%04x" Modifier#VOLATILE.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    add(int mod)
     
    Gets the modifier of a class, field, method or constructor.
    boolean
    isSet(int mod)
    Checks whether this flag is set using mask() on the given modifier flag list.
    static boolean
    isSet(int mod, XAccessFlag... flags)
    Checks whether all the given flags are set using mask() on the given modifier flag list.
    @NotNull @Unmodifiable Set<XAccessFlag.JVMLocation>
    Kinds of constructs the flag can be applied to in the latest class file format version (not the current).
    int
    The corresponding integer mask for the access flag.
    of(int mod)
     
    int
    remove(int mod)
     
    boolean
    Whether the flag has a directly corresponding modifier in the Java programming language.
    static String
    toString(int mod)
    Prints a string interpretation of the flags that are contained in the given modifier flag list in form of Flags::(flag1 flag2 flag3 ...)
    Returns the enum constant of this class with the specified name.
    static XAccessFlag[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • PUBLIC

      public static final XAccessFlag PUBLIC
      The access flag ACC_PUBLIC, corresponding to the source modifier public, with a mask value of "0x%04x" Modifier#PUBLIC.
    • PRIVATE

      public static final XAccessFlag PRIVATE
      The access flag ACC_PRIVATE, corresponding to the source modifier private, with a mask value of "0x%04x" Modifier#PRIVATE.
    • PROTECTED

      public static final XAccessFlag PROTECTED
      The access flag ACC_PROTECTED, corresponding to the source modifier protected, with a mask value of "0x%04x" Modifier#PROTECTED.
    • STATIC

      public static final XAccessFlag STATIC
      The access flag ACC_STATIC, corresponding to the source modifier static, with a mask value of "0x%04x" Modifier#STATIC.
    • FINAL

      public static final XAccessFlag FINAL
      The access flag ACC_FINAL, corresponding to the source modifier final, with a mask value of "0x%04x" Modifier#FINAL.
    • SUPER

      public static final XAccessFlag SUPER
      The access flag ACC_SUPER with a mask value of 0x0020.
    • OPEN

      public static final XAccessFlag OPEN
      The module flag ACC_OPEN with a mask value of 0x0020.
      Since:
      Java 9
      See Also:
    • TRANSITIVE

      public static final XAccessFlag TRANSITIVE
      The module requires flag ACC_TRANSITIVE with a mask value of 0x0020.
      See Also:
    • SYNCHRONIZED

      public static final XAccessFlag SYNCHRONIZED
      The access flag ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of "0x%04x" Modifier#SYNCHRONIZED.
    • STATIC_PHASE

      public static final XAccessFlag STATIC_PHASE
      The module requires flag ACC_STATIC_PHASE with a mask value of 0x0040.
      See Also:
    • VOLATILE

      public static final XAccessFlag VOLATILE
      The access flag ACC_VOLATILE, corresponding to the source modifier volatile, with a mask value of "0x%04x" Modifier#VOLATILE.
    • BRIDGE

      public static final XAccessFlag BRIDGE
      The access flag ACC_BRIDGE with a mask value of "0x%04x" Modifier#BRIDGE
      Since:
      Java 8
      See Also:
    • TRANSIENT

      public static final XAccessFlag TRANSIENT
      The access flag ACC_TRANSIENT, corresponding to the source modifier transient, with a mask value of "0x%04x" Modifier#TRANSIENT.
    • VARARGS

      public static final XAccessFlag VARARGS
      The access flag ACC_VARARGS with a mask value of "0x%04x" Modifier#VARARGS.
      Since:
      Java 5
      See Also:
    • NATIVE

      public static final XAccessFlag NATIVE
      The access flag ACC_NATIVE, corresponding to the source modifier native, with a mask value of "0x%04x" Modifier#NATIVE.
    • INTERFACE

      public static final XAccessFlag INTERFACE
      The access flag ACC_INTERFACE with a mask value of 0x0200.
      See Also:
    • ABSTRACT

      public static final XAccessFlag ABSTRACT
      The access flag ACC_ABSTRACT, corresponding to the source modifier abstract, with a mask value of "0x%04x" Modifier#ABSTRACT.
    • STRICT

      public static final XAccessFlag STRICT
      The access flag ACC_STRICT, corresponding to the source modifier strictfp, with a mask value of "0x%04x" Modifier#STRICT.
      Since:
      Java 1.2
    • SYNTHETIC

      public static final XAccessFlag SYNTHETIC
      The access flag ACC_SYNTHETIC with a mask value of "0x%04x" Modifier#SYNTHETIC.
      See Also:
    • ANNOTATION

      public static final XAccessFlag ANNOTATION
      The access flag ACC_ANNOTATION with a mask value of "0x%04x" Modifier#ANNOTATION.
      Since:
      Java 5
      See Also:
    • ENUM

      public static final XAccessFlag ENUM
      The access flag ACC_ENUM with a mask value of "0x%04x" Modifier#ENUM.
      Since:
      Java 5
      See Also:
    • MANDATED

      public static final XAccessFlag MANDATED
      The access flag ACC_MANDATED with a mask value of "0x%04x" Modifier#MANDATED.
    • MODULE

      public static final XAccessFlag MODULE
      The access flag ACC_MODULE with a mask value of 0x8000.
      Since:
      Java 9
  • Method Details

    • values

      public static XAccessFlag[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static XAccessFlag valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • mask

      @MagicConstant(flagsFromClass=XAccessFlag.class) @Contract(pure=true) public int mask()
      The corresponding integer mask for the access flag.
    • sourceModifier

      @Contract(pure=true) public boolean sourceModifier()
      Whether the flag has a directly corresponding modifier in the Java programming language.

      In most cases this'd mean that you can find the flag name inside Modifier as well. An exception to this rule would be Modifier.INTERFACE

    • locations

      @NotNull @Contract(pure=true) public @NotNull @Unmodifiable Set<XAccessFlag.JVMLocation> locations()
      Kinds of constructs the flag can be applied to in the latest class file format version (not the current).
    • of

      @Contract(pure=true) public static Set<XAccessFlag> of(int mod)
      Parameters:
      mod - Can be Class.getModifiers() or Member.getModifiers().
      See Also:
    • add

      @Contract(pure=true) public int add(int mod)
    • remove

      @Contract(pure=true) public int remove(int mod)
    • isSet

      @Contract(pure=true) public boolean isSet(int mod)
      Checks whether this flag is set using mask() on the given modifier flag list.
      Parameters:
      mod - Can be Class.getModifiers() or Member.getModifiers().
      See Also:
    • isSet

      @Contract(pure=true) public static boolean isSet(int mod, XAccessFlag... flags)
      Checks whether all the given flags are set using mask() on the given modifier flag list.
      Parameters:
      mod - Can be Class.getModifiers() or Member.getModifiers().
      See Also:
    • getModifiers

      @Contract(pure=true) public static Optional<Integer> getModifiers(Object jvm)
      Gets the modifier of a class, field, method or constructor.
      Parameters:
      jvm - must be a Class or Member.
      Returns:
      Optional.empty() if this type doesn't have a modifier.
      See Also:
    • toString

      @Contract(pure=true) public static String toString(int mod)
      Prints a string interpretation of the flags that are contained in the given modifier flag list in form of Flags::(flag1 flag2 flag3 ...)
      Parameters:
      mod - Can be Class.getModifiers() or Member.getModifiers().