Package com.robinloom.jweaver.dynamic
Class DynamicWeaver
java.lang.Object
com.robinloom.jweaver.dynamic.DynamicWeaver
DynamicWeaver generates a string representation for a given object by combining
the object information (class name, field names, values) with a set of separator strings.
The set of separator strings is dynamically configurable.
Example:
Person[name=John Doe, birthday=1990-01-01]
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEnables capitalization of field names.classNameFieldsSeparator(String separator) Sets a string to separate the class name and the fields to be printed.classNamePrefix(String classNamePrefix) Sets a string to be placed before the class name.classNameSuffix(String classNameSuffix) Sets a string to be placed after the class name.excludeFields(List<String> fields) Sets the names of fields that should be excluded from the output.fieldSeparator(String separator) Sets a string that is used to separate the printed fields.fieldValueSeparator(String separator) Sets a string to separate the field name and the corresponding value.globalSuffix(String suffix) Sets a string that is placed at the end of the generated string.includeFields(List<String> fields) Sets the names of fields that should be included in the output.maxSequenceLength(int maxSequenceLength) Sets the maximum length of collections and arrays to be included in the output.Sets newline '\n' as separator for fields and for classname and fields.Enables the printing of data typesActivates the inclusion of inherited fields.Generates a string representation of the given object via reflections.
-
Field Details
-
history
-
-
Constructor Details
-
DynamicWeaver
public DynamicWeaver()
-
-
Method Details
-
multiline
Sets newline '\n' as separator for fields and for classname and fields. The result will be a multiline output.- Returns:
- instance for chaining
-
classNamePrefix
Sets a string to be placed before the class name. Default is empty string.- Parameters:
classNamePrefix- the string to use- Returns:
- instance for chaining
-
classNameSuffix
Sets a string to be placed after the class name. Default is empty string.- Parameters:
classNameSuffix- the string to use- Returns:
- instance for chaining
-
classNameFieldsSeparator
Sets a string to separate the class name and the fields to be printed. Will be between the class name suffix and the first field. Default string is "[".- Parameters:
separator- the separator string to use- Returns:
- instance for chaining
-
fieldValueSeparator
Sets a string to separate the field name and the corresponding value. Default string is "=".- Parameters:
separator- the separator string to use- Returns:
- instance for chaining
-
fieldSeparator
Sets a string that is used to separate the printed fields. Default string is ","- Parameters:
separator- the separator string to use.- Returns:
- instance for chaining
-
globalSuffix
Sets a string that is placed at the end of the generated string. Default string is "]".- Parameters:
suffix- the string to be used.- Returns:
- instance for chaining.
-
maxSequenceLength
Sets the maximum length of collections and arrays to be included in the output. Elements that exceed the limit will be summarized (... 57 more).- Parameters:
maxSequenceLength- an integer value- Returns:
- instance for chaining
-
includeFields
Sets the names of fields that should be included in the output. By default, every field is included.- Parameters:
fields- list of strings containing included field names- Returns:
- instance for chaining
-
excludeFields
Sets the names of fields that should be excluded from the output. By default, no field is excluded.- Parameters:
fields- list of strings containing excluded field names- Returns:
- instance for chaining
-
capitalizeFields
Enables capitalization of field names. firstName -> FirstName- Returns:
- instance for chaining
-
showDataTypes
Enables the printing of data types- Returns:
- instance for chaining
-
showInheritedFields
Activates the inclusion of inherited fields.- Returns:
- instance for chaining
-
weave
Generates a string representation of the given object via reflections. Prints the class name followed by every accessible field. For JDK classes, a regulartoString()result is returned. Detects reciprocal and circular object dependencies.- Parameters:
object- object to generate a string representation for- Returns:
- a well-structured, human-readable representation of that object
-