Class CodeWriterDebugInfo

java.lang.Object
software.amazon.smithy.utils.CodeWriterDebugInfo

public final class CodeWriterDebugInfo extends Object
Provides debug information about the current state of a CodeWriter.

The primary use case of this class is to be included in things like exception messages thrown by CodeWriter. Additional metadata can be appended to the debug info by calling putMetadata(java.lang.String, java.lang.String), and this metadata will appear when toString() is called.

  • Method Details

    • getStateDebugPath

      public String getStateDebugPath()
      Get the CodeWriter state path from which the debug information was collected.
      Returns:
      Returns the path as returned by AbstractCodeWriter.getDebugInfo();
    • putMetadata

      public void putMetadata(String key, String value)
      Put additional debug metadata on the object.
      Parameters:
      key - Name of the value to set.
      value - Value to set that cannot be null.
    • getMetadata

      public String getMetadata(String key)
      Gets debug metadata by name.
      Parameters:
      key - Value to retrieve.
      Returns:
      Returns the string value or null if not found.
    • toString

      public String toString()
      Returns a string representation that can be used in exception messages and when debugging.
      Overrides:
      toString in class Object
      Returns:
      Returns debug info as a string.