@HashCodeAndEqualsPlugin.Enhance public class ToStringMethod extends Object implements Implementation
Object.toString()
that concatenates the String
representation of all fields that are declared by a class.Modifier and Type | Class and Description |
---|---|
protected static class |
ToStringMethod.Appender
An appender to implement
ToStringMethod . |
static interface |
ToStringMethod.PrefixResolver
A prefix resolver is responsible for providing a value that is prepended to a
Object.toString() implementation. |
protected static class |
ToStringMethod.ValueConsumer
A value consumer that is responsible for adding a field value to the string creating
StringBuilder . |
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
InstrumentedType.Prepareable.NoOp
Modifier | Constructor and Description |
---|---|
protected |
ToStringMethod(ToStringMethod.PrefixResolver prefixResolver)
Creates a new
toString implementation. |
Modifier and Type | Method and Description |
---|---|
ToStringMethod.Appender |
appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.
|
static ToStringMethod |
prefixedBy(String prefix)
Creates a
Object.toString() implementation that is prefixed by the supplied string. |
static ToStringMethod |
prefixedBy(ToStringMethod.PrefixResolver prefixResolver)
Creates a
Object.toString() implementation that is prefixed by the string that is supplied by the given prefix resolver. |
static ToStringMethod |
prefixedByCanonicalClassName()
Creates a
Object.toString() implementation that is prefixed by the canonical class name of the instrumented type. |
static ToStringMethod |
prefixedByFullyQualifiedClassName()
Creates a
Object.toString() implementation that is prefixed by the fully qualified class name of the instrumented type. |
static ToStringMethod |
prefixedBySimpleClassName()
Creates a
Object.toString() implementation that is prefixed by the simple class name of the instrumented type. |
InstrumentedType |
prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.
|
ToStringMethod |
withIgnoredFields(ElementMatcher<? super FieldDescription.InDefinedShape> ignored)
Returns a new version of this toString method implementation that ignores the specified fields additionally to any
previously specified fields.
|
Implementation |
withTokens(String start,
String end,
String separator,
String definer)
Changes the tokens used for the
Object.toString() implementation. |
protected ToStringMethod(ToStringMethod.PrefixResolver prefixResolver)
toString
implementation.prefixResolver
- A resolver for the prefix of a String
representation.public static ToStringMethod prefixedByFullyQualifiedClassName()
Object.toString()
implementation that is prefixed by the fully qualified class name of the instrumented type.Object.toString()
implementation that is prefixed by the fully qualified class name of the instrumented type.public static ToStringMethod prefixedByCanonicalClassName()
Object.toString()
implementation that is prefixed by the canonical class name of the instrumented type.Object.toString()
implementation that is prefixed by the canonical class name of the instrumented type.public static ToStringMethod prefixedBySimpleClassName()
Object.toString()
implementation that is prefixed by the simple class name of the instrumented type.Object.toString()
implementation that is prefixed by the simple class name of the instrumented type.public static ToStringMethod prefixedBy(String prefix)
Object.toString()
implementation that is prefixed by the supplied string.prefix
- The prefix to use.Object.toString()
implementation that is prefixed by the supplied string.public static ToStringMethod prefixedBy(ToStringMethod.PrefixResolver prefixResolver)
Object.toString()
implementation that is prefixed by the string that is supplied by the given prefix resolver.prefixResolver
- The prefix resolver to use.Object.toString()
implementation that is prefixed by the string that is supplied by the given prefix resolver.public ToStringMethod withIgnoredFields(ElementMatcher<? super FieldDescription.InDefinedShape> ignored)
ignored
- A matcher to specify any fields that should be ignored.public Implementation withTokens(String start, String end, String separator, String definer)
Object.toString()
implementation.start
- A token that is added between the prefix and the first field value.end
- A token that is added after the last field value.separator
- A token that is added between two field values.definer
- A token that is added between two field values.public InstrumentedType prepare(InstrumentedType instrumentedType)
prepare
in interface InstrumentedType.Prepareable
instrumentedType
- The instrumented type in its current form.public ToStringMethod.Appender appender(Implementation.Target implementationTarget)
appender
in interface Implementation
implementationTarget
- The target of the current implementation.InstrumentedType.Prepareable.prepare(InstrumentedType)
.Copyright © 2014–2024. All rights reserved.