Enum TypeValidation

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<TypeValidation>

    public enum TypeValidation
    extends java.lang.Enum<TypeValidation>

    If type validation is enabled, Byte Buddy performs several checks to ensure that a generated class file is specified in a valid manner. This involves checks of the generated instrumented type and checks of the generated byte code. Byte Buddy's Implementation instances perform their own checks, independently of any type validation.

    The JVM's verifier performs its own checks; an illegal class file is never loaded. However, Byte Buddy's checks might be more expressive in the context of using the library. Also, Byte Buddy emits exceptions at class creation time while the JVM emits errors at class loading time.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      DISABLED
      Disables Byte Buddy's validation.
      ENABLED
      Enables Byte Buddy's validation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean enabled
      true if type validation is enabled.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TypeValidation​(boolean enabled)
      Creates a new type validation enumeration.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isEnabled()
      Returns true if type validation is enabled.
      static TypeValidation of​(boolean enabled)
      Returns ENABLED if the supplied argument is true.
      static TypeValidation valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static TypeValidation[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

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

      • ENABLED

        public static final TypeValidation ENABLED
        Enables Byte Buddy's validation.
      • DISABLED

        public static final TypeValidation DISABLED
        Disables Byte Buddy's validation.
    • Field Detail

      • enabled

        private final boolean enabled
        true if type validation is enabled.
    • Constructor Detail

      • TypeValidation

        private TypeValidation​(boolean enabled)
        Creates a new type validation enumeration.
        Parameters:
        enabled - true if type validation is enabled.
    • Method Detail

      • values

        public static TypeValidation[] 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 (TypeValidation c : TypeValidation.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TypeValidation valueOf​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • of

        public static TypeValidation of​(boolean enabled)
        Returns ENABLED if the supplied argument is true.
        Parameters:
        enabled - true if type validation should be enabled.
        Returns:
        A suitable type validation representation.
      • isEnabled

        public boolean isEnabled()
        Returns true if type validation is enabled.
        Returns:
        true if type validation is enabled.