@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.UsingReflection
Plugin.Compound, Plugin.Engine, Plugin.Factory, Plugin.ForElementMatcher, Plugin.NoOp
ElementMatcher.Junction<S>
Constructor and Description |
---|
CachedReturnPlugin()
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.
|
matches
public CachedReturnPlugin()
public Plugin make()
make
in interface Plugin.Factory
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)
apply
in interface Plugin
builder
- 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 Closeable
close
in interface AutoCloseable
Copyright © 2014–2019. All rights reserved.