public interface DescriptionWriter
Accumulate a description of an object (or objects). Object descriptions should reflect the complete identity of an object - enough to uniquely distinguish it from non-equivalent objects - but are not (usually) a full serialization. They are more verbose than Object.toString()
, and are used for things like generating deterministic keys for naming cache files.
Descriptions are composed of fields with values.
Modifier and Type | Method and Description |
---|---|
DescriptionWriter |
putField(java.lang.String name,
byte[] value)
Put a byte array field.
|
DescriptionWriter |
putField(java.lang.String name,
double value)
Put a floating-point field.
|
DescriptionWriter |
putField(java.lang.String name,
long value)
Put an integer field.
|
DescriptionWriter |
putField(java.lang.String name,
java.lang.Object value)
Put an object field into the description.
|
DescriptionWriter |
putField(java.lang.String name,
java.lang.String value)
Put a field into the description.
|
<T> DescriptionWriter |
putField(java.lang.String name,
T value,
Describer<? super T> describer)
Put an object field into the description.
|
DescriptionWriter |
putList(java.lang.String name,
java.lang.Iterable<?> objects)
Put a field with a list of values, using the default describer.
|
<T> DescriptionWriter |
putList(java.lang.String name,
java.lang.Iterable<T> objects,
Describer<? super T> describer)
Put a field with a list of values.
|
DescriptionWriter putField(java.lang.String name, java.lang.String value)
Put a field into the description.
name
- The field name. It cannot begin with an underscore.value
- The field value.DescriptionWriter putField(java.lang.String name, long value)
Put an integer field.
name
- The field name.value
- The field value.putField(String, String)
DescriptionWriter putField(java.lang.String name, double value)
Put a floating-point field.
name
- The field name.value
- The field value.putField(String, String)
DescriptionWriter putField(java.lang.String name, byte[] value)
Put a byte array field.
name
- The field name.value
- The field value.putField(String, String)
DescriptionWriter putField(java.lang.String name, java.lang.Object value)
Put an object field into the description.
name
- The field name. It cannot begin with an underscore.value
- The field value. It is described with Descriptions.defaultDescriber()
}.DescriptionWriter putList(java.lang.String name, java.lang.Iterable<?> objects)
Put a field with a list of values, using the default describer.
name
- The field name.objects
- The list of objects.<T> DescriptionWriter putList(java.lang.String name, java.lang.Iterable<T> objects, Describer<? super T> describer)
Put a field with a list of values.
name
- The field name.objects
- The list of objects.describer
- A describer for the objects.T
- The type of objects in the list.<T> DescriptionWriter putField(java.lang.String name, T value, Describer<? super T> describer)
Put an object field into the description.
name
- The field name. It cannot begin with an underscore.value
- The field value. If it implements Describable
, then it is asked to write its description; otherwise, some default behavior is used.describer
- A describer to describe the value.