Class CardWeaver

java.lang.Object
com.robinloom.jweaver.card.CardWeaver
All Implemented Interfaces:
Weaver

public class CardWeaver extends Object implements Weaver
CardWeaver depicts a given object as a framed card with aligned key-value pairs inside a box. This representation focuses on clarity and aesthetics, making it well-suited for logs, debug output, or summaries.

Example:

╭ User ───────────────╮
│ name  : Alice       │
│ age   : 28          │
│ email : alice@a.com │
╰─────────────────────╯
  • Field Details

  • Constructor Details

    • CardWeaver

      public CardWeaver()
  • Method Details

    • includeFields

      public CardWeaver 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 CardWeaver 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 CardWeaver omitClassName()
      Determines if the class name should be omitted when printing. By default, the class name is included.
      Returns:
      instance for chaining
    • capitalizeFields

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

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

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

      public CardWeaver boxChars(BoxChars boxChars)
      Sets the set of characters to use for the box bordering the content
      Parameters:
      boxChars - the charset to use for the card box
      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 an ordered structure resembling a business card. 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