Class TreeWeaver

java.lang.Object
com.robinloom.jweaver.tree.TreeWeaver
All Implemented Interfaces:
Weaver

public class TreeWeaver extends Object implements Weaver
TreeWeaver depicts a given object and its fields as a tree. This representation is particularly suitable for nested objects. After setting up the tree structure, it is traversed in a depth-first search. The object string is built while traversing the tree.

Example:

Person
|-- name=John Doe
`-- birthday=1990-01-01
  • Constructor Details

    • TreeWeaver

      public TreeWeaver()
  • Method Details

    • weave

      public String weave(Object object)
      Specified by:
      weave in interface Weaver
    • weave

      public String weave(Object object, Mode mode)
      Generates a string representation of the given object via reflections. Prints the class name followed by every accessible field in a tree structure. For JDK classes, a regular toString() result is returned. Detects reciprocal and circular object dependencies.
      Specified by:
      weave in interface Weaver
      Parameters:
      object - object to generate a string representation for
      Returns:
      a well-structured, human-readable representation of that object