Enum AnnotationRetention

java.lang.Object
java.lang.Enum<AnnotationRetention>
net.bytebuddy.implementation.attribute.AnnotationRetention
All Implemented Interfaces:
Serializable, Comparable<AnnotationRetention>, java.lang.constant.Constable

public enum AnnotationRetention extends Enum<AnnotationRetention>
An annotation retention strategy decides if annotations that are contained within a class file are preserved upon redefining or rebasing a method. When annotations are retained, it is important not to define annotations explicitly that are already defined. When annotations are retained, they are retained in their original format, i.e. default values that were not included in the class file are not added or skipped as determined by a AnnotationValueFilter.
  • Enum Constant Details

    • ENABLED

      public static final AnnotationRetention ENABLED
      Enables annotation retention, i.e. annotations within an existing class files are preserved as they are.
    • DISABLED

      public static final AnnotationRetention DISABLED
      Disables annotation retention, i.e. annotations within an existing class files are discarded.
  • Field Details

    • enabled

      private final boolean enabled
      true if annotation retention is enabled.
  • Constructor Details

    • AnnotationRetention

      private AnnotationRetention(boolean enabled)
      Creates an annotation retention strategy.
      Parameters:
      enabled - true if annotation retention is enabled.
  • Method Details

    • values

      public static AnnotationRetention[] 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 AnnotationRetention 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
    • of

      public static AnnotationRetention of(boolean enabled)
      Resolves an annotation retention from a boolean value.
      Parameters:
      enabled - true if annotation retention is enabled.
      Returns:
      An enabled annotation retention if the value is true.
    • isEnabled

      public boolean isEnabled()
      Returns true if annotation retention is enabled.
      Returns:
      true if annotation retention is enabled.