Class LoadedTypeInitializer.ForStaticField
java.lang.Object
net.bytebuddy.implementation.LoadedTypeInitializer.ForStaticField
- All Implemented Interfaces:
Serializable, LoadedTypeInitializer
- Enclosing interface:
LoadedTypeInitializer
@Enhance
public static class LoadedTypeInitializer.ForStaticField
extends Object
implements LoadedTypeInitializer, Serializable
A type initializer for setting a value for a static field.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface LoadedTypeInitializer
LoadedTypeInitializer.Compound, LoadedTypeInitializer.ForStaticField, LoadedTypeInitializer.NoOp -
Constructor Summary
ConstructorsConstructorDescriptionForStaticField(String fieldName, Object value) Creates a newLoadedTypeInitializerfor setting a static field. -
Method Summary
-
Constructor Details
-
ForStaticField
Creates a newLoadedTypeInitializerfor setting a static field.- Parameters:
fieldName- the name of the field.value- The value to be set.
-
-
Method Details
-
onLoad
Callback that is invoked on the creation of an instrumented type. If the loaded type initializer is alive, this method should be implemented empty instead of throwing an exception.- Specified by:
onLoadin interfaceLoadedTypeInitializer- Parameters:
type- The manifestation of the instrumented type.
-
isAlive
public boolean isAlive()Indicates if this initializer is alive and needs to be invoked. This is only meant as a mark. A loaded type initializer that is not alive might still be called and must therefore not throw an exception but rather provide an empty implementation.- Specified by:
isAlivein interfaceLoadedTypeInitializer- Returns:
trueif this initializer is alive.
-