Package net.bytebuddy.build
Class ToStringPlugin
java.lang.Object
net.bytebuddy.build.ToStringPlugin
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Plugin
,Plugin.Factory
,ElementMatcher<TypeDescription>
A build tool plugin that adds a
Object.toString()
and method to a class if the ToStringPlugin.Enhance
annotation is present and no
explicit method declaration was added. This plugin does not need to be closed.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interface
Instructs theToStringPlugin
to generate aObject.toString()
method for the annotated class unless this method is already declared explicitly.static @interface
Determines that the annotated field is excluded from a string representation of theToStringPlugin
.Nested classes/interfaces inherited from interface net.bytebuddy.matcher.ElementMatcher
ElementMatcher.Junction<S>
Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin
Plugin.Engine, Plugin.Factory, Plugin.ForElementMatcher, Plugin.NoOp, Plugin.WithInitialization, Plugin.WithPreprocessor
Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin.Factory
Plugin.Factory.Simple, Plugin.Factory.UsingReflection
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MethodDescription.InDefinedShape
A description of theToStringPlugin.Enhance.includeSyntheticFields()
method.private static final MethodDescription.InDefinedShape
A description of theToStringPlugin.Enhance.prefix()
method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply
(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) Applies this plugin.void
close()
make()
Returns a plugin that can be used for a transformation and which is subsequently closed.boolean
matches
(TypeDescription target) Matches a target against this element matcher.
-
Field Details
-
ENHANCE_PREFIX
A description of theToStringPlugin.Enhance.prefix()
method. -
ENHANCE_INCLUDE_SYNTHETIC_FIELDS
A description of theToStringPlugin.Enhance.includeSyntheticFields()
method.
-
-
Constructor Details
-
ToStringPlugin
public ToStringPlugin()
-
-
Method Details
-
make
Returns a plugin that can be used for a transformation and which is subsequently closed.- Specified by:
make
in interfacePlugin.Factory
- Returns:
- The plugin to use for type transformations.
-
matches
Matches a target against this element matcher.- Specified by:
matches
in interfaceElementMatcher<TypeDescription>
- Parameters:
target
- The instance to be matched ornull
.- Returns:
true
if the given element is matched by this matcher orfalse
otherwise.
-
apply
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) Applies this plugin.- Specified by:
apply
in interfacePlugin
- Parameters:
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.- Returns:
- The supplied builder with additional transformations registered.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-