Enum ConstructorStrategy.Default

    • Enum Constant Detail

      • NO_CONSTRUCTORS

        public static final ConstructorStrategy.Default NO_CONSTRUCTORS
        This strategy is adding no constructors such that the instrumented type will by default not have any. This is legal by Java byte code requirements. However, if no constructor is added manually if this strategy is applied, the type is not constructable without using JVM non-public functionality.
      • DEFAULT_CONSTRUCTOR

        public static final ConstructorStrategy.Default DEFAULT_CONSTRUCTOR
        This strategy is adding a default constructor that calls it's super types default constructor. If no such constructor is defined by the super class, an IllegalArgumentException is thrown. Note that the default constructor needs to be visible to its sub type for this strategy to work. The declared default constructor of the created class is declared public and without annotations.
      • IMITATE_SUPER_CLASS

        public static final ConstructorStrategy.Default IMITATE_SUPER_CLASS
        This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor. Only constructors that are visible to the instrumented type are added, i.e. package-private constructors are only added if the super type is defined in the same package as the instrumented type and private constructors are always skipped.
      • IMITATE_SUPER_CLASS_PUBLIC

        public static final ConstructorStrategy.Default IMITATE_SUPER_CLASS_PUBLIC
        This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor. Only public constructors are added.
      • IMITATE_SUPER_CLASS_OPENING

        public static final ConstructorStrategy.Default IMITATE_SUPER_CLASS_OPENING
        This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor. A constructor is added for any constructor of the super class that is invokable and is declared as public.
    • Constructor Detail

      • Default

        private Default()
    • Method Detail

      • values

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

        public static ConstructorStrategy.Default 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
      • extractConstructors

        public java.util.List<MethodDescription.Token> extractConstructors​(TypeDescription instrumentedType)
        Extracts constructors for a given super type. The extracted constructor signatures will then be imitated by the created dynamic type.
        Specified by:
        extractConstructors in interface ConstructorStrategy
        Parameters:
        instrumentedType - The type for which the constructors should be created.
        Returns:
        A list of tokens that describe the constructors that are to be implemented.
      • resolveModifier

        protected int resolveModifier​(int modifiers)
        Resolves a constructor's modifiers.
        Parameters:
        modifiers - The actual constructor's modifiers.
        Returns:
        The resolved modifiers.
      • doExtractConstructors

        protected abstract java.util.List<MethodDescription.Token> doExtractConstructors​(TypeDescription instrumentedType)
        Extracts the relevant method tokens of the instrumented type's constructors.
        Parameters:
        instrumentedType - The type for which to extract the constructors.
        Returns:
        A list of relevant method tokens.
      • doInject

        protected abstract MethodRegistry doInject​(MethodRegistry methodRegistry,
                                                   MethodAttributeAppender.Factory methodAttributeAppenderFactory)
        Applies the actual injection with a method attribute appender factory supplied.
        Parameters:
        methodRegistry - The method registry into which to inject the constructors.
        methodAttributeAppenderFactory - The method attribute appender to use.
        Returns:
        The resulting method registry.
      • with

        public ConstructorStrategy with​(MethodAttributeAppender.Factory methodAttributeAppenderFactory)
        Returns a constructor strategy that supplies the supplied method attribute appender factory.
        Parameters:
        methodAttributeAppenderFactory - The method attribute appender factory to use.
        Returns:
        A copy of this constructor strategy with the method attribute appender factory applied.
      • withInheritedAnnotations

        public ConstructorStrategy withInheritedAnnotations()
        Applies this constructor strategy while retaining any of the base constructor's annotations.
        Returns:
        A copy of this constructor strategy which retains any of the base constructor's annotations.