Class ConstructorStrategy.ForDefaultConstructor
- java.lang.Object
-
- net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.ForDefaultConstructor
-
- All Implemented Interfaces:
ConstructorStrategy
- Enclosing interface:
- ConstructorStrategy
@Enhance public static class ConstructorStrategy.ForDefaultConstructor extends java.lang.Object implements ConstructorStrategy
A constructor strategy that creates a default constructor that invokes a super constructor with default arguments.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy
ConstructorStrategy.Default, ConstructorStrategy.ForDefaultConstructor
-
-
Field Summary
Fields Modifier and Type Field Description private ElementMatcher<? super MethodDescription>
elementMatcher
A matcher to select a super constructor among possible candidates.private MethodAttributeAppender.Factory
methodAttributeAppenderFactory
The method attribute appender factory to apply.
-
Constructor Summary
Constructors Constructor Description ForDefaultConstructor()
Creates a constructor strategy for invoking a super constructor with default arguments.ForDefaultConstructor(MethodAttributeAppender.Factory methodAttributeAppenderFactory)
Creates a constructor strategy for invoking a super constructor with default arguments.ForDefaultConstructor(ElementMatcher<? super MethodDescription> elementMatcher)
Creates a constructor strategy for invoking a super constructor with default arguments.ForDefaultConstructor(ElementMatcher<? super MethodDescription> elementMatcher, MethodAttributeAppender.Factory methodAttributeAppenderFactory)
Creates a constructor strategy for invoking a super constructor with default arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<MethodDescription.Token>
extractConstructors(TypeDescription instrumentedType)
Extracts constructors for a given super type.MethodRegistry
inject(TypeDescription instrumentedType, MethodRegistry methodRegistry)
Returns a method registry that is capable of creating byte code for the constructors that were provided by theConstructorStrategy.extractConstructors(TypeDescription)
method of this instance.
-
-
-
Field Detail
-
elementMatcher
private final ElementMatcher<? super MethodDescription> elementMatcher
A matcher to select a super constructor among possible candidates.
-
methodAttributeAppenderFactory
private final MethodAttributeAppender.Factory methodAttributeAppenderFactory
The method attribute appender factory to apply.
-
-
Constructor Detail
-
ForDefaultConstructor
public ForDefaultConstructor()
Creates a constructor strategy for invoking a super constructor with default arguments.
-
ForDefaultConstructor
public ForDefaultConstructor(ElementMatcher<? super MethodDescription> elementMatcher)
Creates a constructor strategy for invoking a super constructor with default arguments.- Parameters:
elementMatcher
- A matcher to select a super constructor among possible candidates.
-
ForDefaultConstructor
public ForDefaultConstructor(MethodAttributeAppender.Factory methodAttributeAppenderFactory)
Creates a constructor strategy for invoking a super constructor with default arguments.- Parameters:
methodAttributeAppenderFactory
- The method attribute appender factory to apply.
-
ForDefaultConstructor
public ForDefaultConstructor(ElementMatcher<? super MethodDescription> elementMatcher, MethodAttributeAppender.Factory methodAttributeAppenderFactory)
Creates a constructor strategy for invoking a super constructor with default arguments.- Parameters:
elementMatcher
- A matcher to select a super constructor among possible candidates.methodAttributeAppenderFactory
- The method attribute appender factory to apply.
-
-
Method Detail
-
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 interfaceConstructorStrategy
- 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.
-
inject
public MethodRegistry inject(TypeDescription instrumentedType, MethodRegistry methodRegistry)
Returns a method registry that is capable of creating byte code for the constructors that were provided by theConstructorStrategy.extractConstructors(TypeDescription)
method of this instance.- Specified by:
inject
in interfaceConstructorStrategy
- Parameters:
instrumentedType
- The instrumented type.methodRegistry
- The original method registry.- Returns:
- A method registry that is capable of providing byte code for the constructors that were added by this strategy.
-
-