Class BulletWeaver

java.lang.Object
com.robinloom.jweaver.bullet.BulletWeaver
All Implemented Interfaces:
Weaver

public class BulletWeaver extends Object implements Weaver
BulletWeaver generates a string representation for a given object by arranging the object information (class name, field names, values) in a list with indented items.

Example:

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

    • BulletWeaver

      public BulletWeaver()
  • Method Details

    • firstLevelBulletChar

      public BulletWeaver firstLevelBulletChar(char character)
      Sets the character to be used for a bullet on first level.
      Parameters:
      character - character to be used
      Returns:
      instance for chaining
    • secondLevelBulletChar

      public BulletWeaver secondLevelBulletChar(char character)
      Sets the character to be used for a bullet on second level.
      Parameters:
      character - character to be used
      Returns:
      instance for chaining
    • deeperLevelBulletChar

      public BulletWeaver deeperLevelBulletChar(char character)
      Sets the character to be used for a bullet on third level or deeper.
      Parameters:
      character - character to be used
      Returns:
      instance for chaining
    • indentation

      public BulletWeaver indentation(int indentation)
      Sets the amount of indentation to be applied for every step. Default is 2.
      Parameters:
      indentation - integer for the indentation level
      Returns:
      instance for chaining
    • maxDepth

      public BulletWeaver maxDepth(int maxDepth)
      Sets the maximum depth for the resulting tree.
      Parameters:
      maxDepth - an integer for the maximum depth
      Returns:
      instance for chaining
    • maxSequenceLength

      public BulletWeaver maxSequenceLength(int 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

      public BulletWeaver includeFields(List<String> fields)
      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

      public BulletWeaver excludeFields(List<String> fields)
      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
    • omitClassName

      public BulletWeaver omitClassName()
      Determines if the class name should be omitted when printing. By default, the class name is included.
      Returns:
      instance for chaining
    • capitalizeFields

      public BulletWeaver capitalizeFields()
      Enables capitalization of field names. firstName -> FirstName
      Returns:
      instance for chaining
    • showDataTypes

      public BulletWeaver showDataTypes()
      Enables the printing of data types
      Returns:
      instance for chaining
    • showInheritedFields

      public BulletWeaver showInheritedFields()
      Activates the inclusion of inherited fields.
      Returns:
      instance for chaining
    • weave

      public String weave(Object object)
      Generates a string representation of the given object via reflections. Prints the class name followed by every accessible field in a list 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