@HashCodeAndEqualsPlugin.Enhance public class CachedReturnPlugin extends Plugin.ForElementMatcher implements Plugin.Factory
final fields. In this context, it is possible that
the method is executed multiple times by different threads but at the same time, this approach avoids a volatile field
declaration. For methods with a primitive return type, the type's default value is used to indicate that a method was not yet invoked.
For methods that return a reference type, null is used as an indicator. If a method returns such a value, this mechanism will
not work. This plugin does not need to be closed.| Modifier and Type | Class and Description |
|---|---|
protected static interface |
CachedReturnPlugin.CacheField
Indicates the field that stores the cached value.
|
protected static class |
CachedReturnPlugin.CacheFieldOffsetMapping
An offset mapping for the cached field.
|
static interface |
CachedReturnPlugin.Enhance
Indicates methods that should be cached, i.e.
|
Plugin.Factory.Simple, Plugin.Factory.UsingReflectionPlugin.Engine, Plugin.Factory, Plugin.ForElementMatcher, Plugin.NoOp, Plugin.WithInitialization, Plugin.WithPreprocessorElementMatcher.Junction<S>| Constructor and Description |
|---|
CachedReturnPlugin()
Creates a plugin for caching method return values.
|
CachedReturnPlugin(boolean ignoreExistingFields)
Creates a plugin for caching method return values.
|
| Modifier and Type | Method and Description |
|---|---|
DynamicType.Builder<?> |
apply(DynamicType.Builder<?> builder,
TypeDescription typeDescription,
ClassFileLocator classFileLocator)
Applies this plugin.
|
void |
close() |
Plugin |
make()
Returns a plugin that can be used for a transformation and which is subsequently closed.
|
matchespublic CachedReturnPlugin()
public CachedReturnPlugin(boolean ignoreExistingFields)
ignoreExistingFields - true if existing fields should be ignored if the field name was explicitly given.public Plugin make()
make in interface Plugin.Factorypublic DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)
apply in interface Pluginbuilder - The builder to use as a basis for the applied transformation.typeDescription - The type being transformed.classFileLocator - A class file locator that can locate other types in the scope of the project.public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2014–2023. All rights reserved.