Package net.bytebuddy
Enum ByteBuddy.RecordConstructorStrategy
- java.lang.Object
-
- java.lang.Enum<ByteBuddy.RecordConstructorStrategy>
-
- net.bytebuddy.ByteBuddy.RecordConstructorStrategy
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ByteBuddy.RecordConstructorStrategy>
,InstrumentedType.Prepareable
,ConstructorStrategy
,Implementation
- Enclosing class:
- ByteBuddy
@Enhance protected static enum ByteBuddy.RecordConstructorStrategy extends java.lang.Enum<ByteBuddy.RecordConstructorStrategy> implements ConstructorStrategy, Implementation
A constructor strategy for implementing a Java record.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ByteBuddy.RecordConstructorStrategy.Appender
A byte code appender for accessors and the record constructor.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy
ConstructorStrategy.Default, ConstructorStrategy.ForDefaultConstructor
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
The singleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description private
RecordConstructorStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteCodeAppender
appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.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.InstrumentedType
prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.static ByteBuddy.RecordConstructorStrategy
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ByteBuddy.RecordConstructorStrategy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
INSTANCE
public static final ByteBuddy.RecordConstructorStrategy INSTANCE
The singleton instance.
-
-
Method Detail
-
values
public static ByteBuddy.RecordConstructorStrategy[] 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 (ByteBuddy.RecordConstructorStrategy c : ByteBuddy.RecordConstructorStrategy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ByteBuddy.RecordConstructorStrategy 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 namejava.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 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.
-
appender
public ByteCodeAppender appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.- Specified by:
appender
in interfaceImplementation
- Parameters:
implementationTarget
- The target of the current implementation.- Returns:
- A byte code appender for implementing methods delegated to this implementation. This byte code appender
is also responsible for handling methods that were added by this implementation on the call to
InstrumentedType.Prepareable.prepare(InstrumentedType)
.
-
prepare
public InstrumentedType prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.- Specified by:
prepare
in interfaceInstrumentedType.Prepareable
- Parameters:
instrumentedType
- The instrumented type in its current form.- Returns:
- The prepared instrumented type.
-
-