Enum Visibility

java.lang.Object
java.lang.Enum<Visibility>
org.apache.juneau.Visibility
All Implemented Interfaces:
Serializable, Comparable<Visibility>, java.lang.constant.Constable

public enum Visibility extends Enum<Visibility>
Defines class/field/method visibilities.

Used to specify minimum levels of visibility when detecting bean classes, methods, and fields.

Used in conjunction with the following bean context properties:

See Also:
  • Enum Constant Details

    • NONE

      public static final Visibility NONE
      Ignore all
    • PUBLIC

      public static final Visibility PUBLIC
      Include only public classes/fields/methods.
    • PROTECTED

      public static final Visibility PROTECTED
      Include only public or protected classes/fields/methods.
    • DEFAULT

      public static final Visibility DEFAULT
      Include all but private classes/fields/methods.
    • PRIVATE

      public static final Visibility PRIVATE
      Include all classes/fields/methods.
  • Method Details

    • values

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

      public static Visibility 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
    • isVisible

      public boolean isVisible(int mod)
      Identifies if the specified mod matches this visibility.
      Example:

      PUBLIC.isVisible(MyPublicClass.class.getModifiers()); //true PUBLIC.isVisible(MyPrivateClass.class.getModifiers()); //false PRIVATE.isVisible(MyPrivateClass.class.getModifiers()); //true NONE.isVisible(MyPublicClass.class.getModifiers()); //false

      Parameters:
      mod - The modifier from the object being tested (e.g. results from Class.getModifiers().
      Returns:
      true if this visibility matches the specified modifier attribute.
    • isVisible

      public boolean isVisible(Class<?> x)
      Shortcut for isVisible(x.getModifiers());
      Parameters:
      x - The class to check.
      Returns:
      true if the class is at least as visible as this object.
    • isVisible

      public boolean isVisible(Executable x)
      Shortcut for isVisible(x.getModifiers());
      Parameters:
      x - The constructor to check.
      Returns:
      true if the constructor is at least as visible as this object.
    • isVisible

      public boolean isVisible(Field x)
      Shortcut for isVisible(x.getModifiers());
      Parameters:
      x - The field to check.
      Returns:
      true if the field is at least as visible as this object.
    • transform

      public <T> Constructor<T> transform(Constructor<T> x)
      Makes constructor accessible if it matches the visibility requirements, or returns null if it doesn't.

      Security exceptions thrown on the call to Constructor.setAccessible(boolean) are quietly ignored.

      Type Parameters:
      T - The class type.
      Parameters:
      x - The constructor.
      Returns:
      The same constructor if visibility requirements met, or null if visibility requirement not met or call to Constructor.setAccessible(boolean) throws a security exception.
    • transform

      public Method transform(Method x)
      Makes method accessible if it matches the visibility requirements, or returns null if it doesn't.

      Security exceptions thrown on the call to Method.setAccessible(boolean) are quietly ignored.

      Parameters:
      x - The method.
      Returns:
      The same method if visibility requirements met, or null if visibility requirement not met or call to Method.setAccessible(boolean) throws a security exception.
    • transform

      public Field transform(Field x)
      Makes field accessible if it matches the visibility requirements, or returns null if it doesn't.

      Security exceptions thrown on the call to Field.setAccessible(boolean) are quietly ignored.

      Parameters:
      x - The field.
      Returns:
      The same field if visibility requirements met, or null if visibility requirement not met or call to Field.setAccessible(boolean) throws a security exception.