Class YamlPrintFormat<T>

java.lang.Object
org.approvej.yaml.jackson.YamlPrintFormat<T>
Type Parameters:
T - the type of the object to print
All Implemented Interfaces:
org.approvej.print.PrintFormat<T>

@NullMarked public final class YamlPrintFormat<T> extends Object implements org.approvej.print.PrintFormat<T>
A PrintFormat that uses ObjectWriter.writeValueAsString(Object) to print a value as YAML.
  • Constructor Details

    • YamlPrintFormat

      public YamlPrintFormat()
      Default constructor to be used in Configuration.
  • Method Details

    • printer

      public org.approvej.print.Printer<T> printer()
      Specified by:
      printer in interface org.approvej.print.PrintFormat<T>
    • filenameExtension

      public String filenameExtension()
      Specified by:
      filenameExtension in interface org.approvej.print.PrintFormat<T>
    • yaml

      public static <T> YamlPrintFormat<T> yaml(com.fasterxml.jackson.databind.ObjectWriter objectWriter)
      Creates a YamlPrintFormat using the given ObjectWriter.
      Type Parameters:
      T - the type of value to print
      Parameters:
      objectWriter - the ObjectWriter that will be used for printing
      Returns:
      a new YamlPrintFormat instance
    • yaml

      public static <T> YamlPrintFormat<T> yaml(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Creates a YamlPrintFormat using the given ObjectMapper.
      Type Parameters:
      T - the type of value to print
      Parameters:
      objectMapper - the ObjectMapper used to create the ObjectWriter
      Returns:
      a new YamlPrintFormat instance
      See Also:
      • ObjectMapper.writerWithDefaultPrettyPrinter()
    • yaml

      public static <T> YamlPrintFormat<T> yaml()
      Creates a YamlPrintFormat using the default YAMLMapper.
      Type Parameters:
      T - the type of value to print
      Returns:
      a new YamlPrintFormat instance
      See Also:
      • MapperBuilder.build()