Top Description Inners Fields Constructors Methods
net.bytebuddy.build

public Class ToStringPlugin

extends Object
implements Plugin, Factory
Class Inheritance
All Implemented Interfaces
net.bytebuddy.build.Plugin.Factory, net.bytebuddy.build.Plugin, java.io.Closeable, java.lang.AutoCloseable, net.bytebuddy.matcher.ElementMatcher
Annotations
@Enhance
Imports
net.bytebuddy.description.annotation.AnnotationDescription, net.bytebuddy.description.field.FieldDescription, net.bytebuddy.description.method.MethodDescription, .MethodList, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.dynamic.ClassFileLocator, .DynamicType, net.bytebuddy.implementation.ToStringMethod, net.bytebuddy.matcher.ElementMatchers, net.bytebuddy.utility.nullability.MaybeNull, java.lang.annotation.*

A build tool plugin that adds a Object#toString() and method to a class if the Enhance annotation is present and no explicit method declaration was added. This plugin does not need to be closed.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static @interface
ToStringPlugin.Enhance

Instructs the ToStringPlugin to generate a Object#toString() method for the annotated class unless this method is already declared explicitly.

public static @interface
ToStringPlugin.Exclude

Determines that the annotated field is excluded from a string representation of the ToStringPlugin.

Field Summary

Modifier and TypeField and Description
private static final MethodDescription.InDefinedShape
private static final MethodDescription.InDefinedShape
ENHANCE_PREFIX

A description of the Enhance#prefix() method.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public DynamicType.Builder<?>
apply(DynamicType.Builder<?>
The builder to use as a basis for the applied transformation.
builder
,
TypeDescription
The type being transformed.
typeDescription
,
ClassFileLocator
A class file locator that can locate other types in the scope of the project.
classFileLocator
)

Implements net.bytebuddy.build.Plugin.apply.

Applies this plugin.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public Plugin
make()

Implements net.bytebuddy.build.Plugin.Factory.make.

Returns a plugin that can be used for a transformation and which is subsequently closed.
public boolean
matches(TypeDescription
The instance to be matched or null.
target
)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ENHANCE_INCLUDE_SYNTHETIC_FIELDSback to summary
private static final MethodDescription.InDefinedShape ENHANCE_INCLUDE_SYNTHETIC_FIELDS

A description of the Enhance#includeSyntheticFields() method.

ENHANCE_PREFIXback to summary
private static final MethodDescription.InDefinedShape ENHANCE_PREFIX

A description of the Enhance#prefix() method.

Constructor Detail

ToStringPluginback to summary
public ToStringPlugin()

Method Detail

applyback to summary
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)

Implements net.bytebuddy.build.Plugin.apply.

Doc from net.bytebuddy.build.Plugin.apply.

Applies this plugin.

Parameters
builder:DynamicType.Builder<?>

The builder to use as a basis for the applied transformation.

typeDescription:TypeDescription

The type being transformed.

classFileLocator:ClassFileLocator

A class file locator that can locate other types in the scope of the project.

Returns:DynamicType.Builder<?>

The supplied builder with additional transformations registered.

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

makeback to summary
public Plugin make()

Implements net.bytebuddy.build.Plugin.Factory.make.

Doc from net.bytebuddy.build.Plugin.Factory.make.

Returns a plugin that can be used for a transformation and which is subsequently closed.

Returns:Plugin

The plugin to use for type transformations.

matchesback to summary
public boolean matches(TypeDescription target)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Doc from net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.

Parameters
target:TypeDescription

The instance to be matched or null.

Returns:boolean

true if the given element is matched by this matcher or false otherwise.

net.bytebuddy.build back to summary

public @Interface ToStringPlugin.Enhance

extends Annotation
Annotations
@Documented
@Target:TYPE
@Retention:RUNTIME

Instructs the ToStringPlugin to generate a Object#toString() method for the annotated class unless this method is already declared explicitly.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ToStringPlugin.Enhance.Prefix

A strategy for defining a prefix.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if synthetic fields should be included.
includeSyntheticFields
()

Determines if synthetic fields should be included in the string representation.

public ToStringPlugin.Enhance.Prefix

Returns:

The prefix to use.
prefix
()

Determines the prefix to be used for the string representation prior to adding field values.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

includeSyntheticFieldsback to summary
public boolean includeSyntheticFields()

Determines if synthetic fields should be included in the string representation.

Returns:boolean

true if synthetic fields should be included.

prefixback to summary
public ToStringPlugin.Enhance.Prefix prefix()

Determines the prefix to be used for the string representation prior to adding field values.

Returns:ToStringPlugin.Enhance.Prefix

The prefix to use.

net.bytebuddy.build back to summary

public final Enum ToStringPlugin.Enhance.Prefix

extends Enum<ToStringPlugin.Enhance.Prefix>
Class Inheritance

A strategy for defining a prefix.

Field Summary

Modifier and TypeField and Description
public static final ToStringPlugin.Enhance.Prefix
CANONICAL

Determines the use of the canonical class name as a prefix.

public static final ToStringPlugin.Enhance.Prefix
FULLY_QUALIFIED

Determines the use of a fully qualified class name as a prefix.

private final ToStringMethod.PrefixResolver.Default
prefixResolver

The prefix resolver to use.

public static final ToStringPlugin.Enhance.Prefix
SIMPLE

Determines the use of the simple class name as a prefix.

Constructor Summary

AccessConstructor and Description
private
Prefix(ToStringMethod.PrefixResolver.Default
The prefix resolver to use.
prefixResolver
)

Creates a new prefix.

Method Summary

Modifier and TypeMethod and Description
protected ToStringMethod.PrefixResolver.Default

Returns:

The prefix resolver to use.
getPrefixResolver
()

Returns the prefix resolver to use.

public static ToStringPlugin.Enhance.Prefix
public static ToStringPlugin.Enhance.Prefix[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CANONICALback to summary
public static final ToStringPlugin.Enhance.Prefix CANONICAL

Determines the use of the canonical class name as a prefix.

FULLY_QUALIFIEDback to summary
public static final ToStringPlugin.Enhance.Prefix FULLY_QUALIFIED

Determines the use of a fully qualified class name as a prefix.

prefixResolverback to summary
private final ToStringMethod.PrefixResolver.Default prefixResolver

The prefix resolver to use.

SIMPLEback to summary
public static final ToStringPlugin.Enhance.Prefix SIMPLE

Determines the use of the simple class name as a prefix.

Constructor Detail

Prefixback to summary
private Prefix(ToStringMethod.PrefixResolver.Default prefixResolver)

Creates a new prefix.

Parameters
prefixResolver:ToStringMethod.PrefixResolver.Default

The prefix resolver to use.

Method Detail

getPrefixResolverback to summary
protected ToStringMethod.PrefixResolver.Default getPrefixResolver()

Returns the prefix resolver to use.

Returns:ToStringMethod.PrefixResolver.Default

The prefix resolver to use.

valueOfback to summary
public static ToStringPlugin.Enhance.Prefix valueOf(String name)
valuesback to summary
public static ToStringPlugin.Enhance.Prefix[] values()
net.bytebuddy.build back to summary

public @Interface ToStringPlugin.Exclude

extends Annotation
Annotations
@Documented
@Target:FIELD
@Retention:RUNTIME

Determines that the annotated field is excluded from a string representation of the ToStringPlugin.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString