public abstract class ObfuscatingToStringStyle extends ToStringStyle
ToStringStyle
that can obfuscate fields.
An ObfuscatingToStringStyle
object is not thread safe nor stateless, and should not be reused for multiple objects concurrently.
However, a ObfuscatingToStringStyle.Builder
can build immutable Suppliers
of ObfuscatingToStringStyle
which can be safely reused
for multiple objects and in multiple threads. Such a Supplier
can be used directly, or perhaps in combination with
ThreadLocal.withInitial(Supplier)
. For instance, in a class:
private static final Supplier<ObfuscatingToStringStyle> TO_STRING_STYLE = ObfuscatingToStringStyle.defaultStyle()
...
.supplier();
...
public String toString() {
return ToStringBuilder.reflectionToString(this, TO_STRING_STYLE.get());
}
Note: instances of ObfuscatingToStringStyle
are not serializable.
Modifier and Type | Class and Description |
---|---|
static class |
ObfuscatingToStringStyle.Builder
A builder for creating obfuscating
ToStringStyle objects. |
static class |
ObfuscatingToStringStyle.FieldConfigurer
An object that can be used to configure a field that should be obfuscated.
|
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE
Modifier | Constructor and Description |
---|---|
protected |
ObfuscatingToStringStyle(ObfuscatingToStringStyle.Builder.Snapshot snapshot)
Creates a new obfuscating
ToStringStyle . |
protected |
ObfuscatingToStringStyle(ObfuscatingToStringStyle.Builder builder)
Creates a new obfuscating
ToStringStyle . |
Modifier and Type | Method and Description |
---|---|
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
boolean value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
boolean[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
byte value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
byte[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
char value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
char[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Collection<?> coll) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
double value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
double[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
float value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
float[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
int value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
int[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
long value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
long[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Map<?,?> map) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Object value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Object[] array) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
short value) |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
short[] array) |
protected void |
appendNullText(StringBuffer buffer,
String fieldName) |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
Object value) |
protected void |
appendSummarySize(StringBuffer buffer,
String fieldName,
int size) |
static ObfuscatingToStringStyle.Builder |
defaultStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to ToStringStyle.DEFAULT_STYLE . |
static ObfuscatingToStringStyle.Builder |
multiLineRecursiveStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
MultilineRecursiveToStringStyle . |
static ObfuscatingToStringStyle.Builder |
multiLineRecursiveStyle(Predicate<? super Class<?>> recurseIntoPredicate)
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
MultilineRecursiveToStringStyle . |
static ObfuscatingToStringStyle.Builder |
multiLineStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to ToStringStyle.MULTI_LINE_STYLE . |
static ObfuscatingToStringStyle.Builder |
noClassNameStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
ToStringStyle.NO_CLASS_NAME_STYLE . |
static ObfuscatingToStringStyle.Builder |
noFieldNamesStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
ToStringStyle.NO_FIELD_NAMES_STYLE . |
static ObfuscatingToStringStyle.Builder |
recursiveStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
RecursiveToStringStyle . |
static ObfuscatingToStringStyle.Builder |
recursiveStyle(Predicate<? super Class<?>> recurseIntoPredicate)
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
RecursiveToStringStyle . |
protected void |
reflectionAppendArrayDetail(StringBuffer buffer,
String fieldName,
Object array) |
static ObfuscatingToStringStyle.Builder |
shortPrefixStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to
ToStringStyle.SHORT_PREFIX_STYLE . |
static ObfuscatingToStringStyle.Builder |
simpleStyle()
Returns a builder that creates obfuscating
ToStringStyle objects that produce output similar to ToStringStyle.SIMPLE_STYLE . |
append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, appendClassName, appendContentEnd, appendContentStart, appendCyclicObject, appendDetail, appendEnd, appendFieldEnd, appendFieldSeparator, appendFieldStart, appendIdentityHashCode, appendInternal, appendStart, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSuper, appendToString, getArrayEnd, getArraySeparator, getArrayStart, getContentEnd, getContentStart, getFieldNameValueSeparator, getFieldSeparator, getNullText, getShortClassName, getSizeEndText, getSizeStartText, getSummaryObjectEndText, getSummaryObjectStartText, isArrayContentDetail, isDefaultFullDetail, isFieldSeparatorAtEnd, isFieldSeparatorAtStart, isFullDetail, isUseClassName, isUseFieldNames, isUseIdentityHashCode, isUseShortClassName, removeLastFieldSeparator, setArrayContentDetail, setArrayEnd, setArraySeparator, setArrayStart, setContentEnd, setContentStart, setDefaultFullDetail, setFieldNameValueSeparator, setFieldSeparator, setFieldSeparatorAtEnd, setFieldSeparatorAtStart, setNullText, setSizeEndText, setSizeStartText, setSummaryObjectEndText, setSummaryObjectStartText, setUseClassName, setUseFieldNames, setUseIdentityHashCode, setUseShortClassName
protected ObfuscatingToStringStyle(ObfuscatingToStringStyle.Builder builder)
ToStringStyle
.builder
- The builder with the settings to use for creating the obfuscating ToStringStyle
.NullPointerException
- If the given builder is null
.protected ObfuscatingToStringStyle(ObfuscatingToStringStyle.Builder.Snapshot snapshot)
ToStringStyle
.snapshot
- A builder snapshot with the settings to use for creating the obfuscating ToStringStyle
.NullPointerException
- If the given snapshot is null
.protected void appendDetail(StringBuffer buffer, String fieldName, Object value)
appendDetail
in class ToStringStyle
protected void appendSummary(StringBuffer buffer, String fieldName, Object value)
appendSummary
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, Map<?,?> map)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, long value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, int value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, short value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, byte value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, char value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, double value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, float value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, boolean value)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, Object[] array)
appendDetail
in class ToStringStyle
protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)
reflectionAppendArrayDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, long[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, int[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, short[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, byte[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, char[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, double[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, float[] array)
appendDetail
in class ToStringStyle
protected void appendDetail(StringBuffer buffer, String fieldName, boolean[] array)
appendDetail
in class ToStringStyle
protected void appendNullText(StringBuffer buffer, String fieldName)
appendNullText
in class ToStringStyle
protected void appendSummarySize(StringBuffer buffer, String fieldName, int size)
appendSummarySize
in class ToStringStyle
public static ObfuscatingToStringStyle.Builder defaultStyle()
ToStringStyle
objects that produce output similar to ToStringStyle.DEFAULT_STYLE
.ToStringStyle
objects that produce output similar to ToStringStyle.DEFAULT_STYLE
.public static ObfuscatingToStringStyle.Builder multiLineStyle()
ToStringStyle
objects that produce output similar to ToStringStyle.MULTI_LINE_STYLE
.ToStringStyle
objects that produce output similar to ToStringStyle.MULTI_LINE_STYLE
.public static ObfuscatingToStringStyle.Builder noFieldNamesStyle()
ToStringStyle
objects that produce output similar to
ToStringStyle.NO_FIELD_NAMES_STYLE
.ToStringStyle
objects that produce output similar to
ToStringStyle.NO_FIELD_NAMES_STYLE
.public static ObfuscatingToStringStyle.Builder shortPrefixStyle()
ToStringStyle
objects that produce output similar to
ToStringStyle.SHORT_PREFIX_STYLE
.ToStringStyle
objects that produce output similar to
ToStringStyle.SHORT_PREFIX_STYLE
.public static ObfuscatingToStringStyle.Builder simpleStyle()
ToStringStyle
objects that produce output similar to ToStringStyle.SIMPLE_STYLE
.ToStringStyle
objects that produce output similar to ToStringStyle.SIMPLE_STYLE
.public static ObfuscatingToStringStyle.Builder noClassNameStyle()
ToStringStyle
objects that produce output similar to
ToStringStyle.NO_CLASS_NAME_STYLE
.ToStringStyle
objects that produce output similar to
ToStringStyle.NO_CLASS_NAME_STYLE
.public static ObfuscatingToStringStyle.Builder recursiveStyle()
ToStringStyle
objects that produce output similar to
RecursiveToStringStyle
.
This method is similar to calling recursiveStyle(Predicate)
with a predicate that always returns true
.ToStringStyle
objects that produce output similar to
RecursiveToStringStyle
.public static ObfuscatingToStringStyle.Builder recursiveStyle(Predicate<? super Class<?>> recurseIntoPredicate)
ToStringStyle
objects that produce output similar to
RecursiveToStringStyle
.recurseIntoPredicate
- A predicate that determines which classes are recursively formatted.
Note that primitive types, primitive wrappers and String
are never recursively formatted.ToStringStyle
objects that produce output similar to
RecursiveToStringStyle
.public static ObfuscatingToStringStyle.Builder multiLineRecursiveStyle()
ToStringStyle
objects that produce output similar to
MultilineRecursiveToStringStyle
.
This method is similar to calling recursiveStyle(Predicate)
with a predicate that always returns true
.ToStringStyle
objects that produce output similar to
RecursiveToStringStyle
.public static ObfuscatingToStringStyle.Builder multiLineRecursiveStyle(Predicate<? super Class<?>> recurseIntoPredicate)
ToStringStyle
objects that produce output similar to
MultilineRecursiveToStringStyle
.recurseIntoPredicate
- A predicate that determines which classes are recursively formatted.
Note that primitive types, primitive wrappers and String
are never recursively formatted.ToStringStyle
objects that produce output similar to
RecursiveToStringStyle
.Copyright © 2020–2022. All rights reserved.