Record Class YamlPrintFormat<T>

java.lang.Object
java.lang.Record
org.approvej.yaml.jackson3.YamlPrintFormat<T>
Type Parameters:
T - the type of the object to print
Record Components:
objectWriter - the ObjectWriter that will be used for printing
All Implemented Interfaces:
org.approvej.configuration.Provider<org.approvej.print.PrintFormat<T>>, org.approvej.print.PrintFormat<T>, org.approvej.print.PrintFormatProvider<T>

@NullMarked public record YamlPrintFormat<T>(tools.jackson.databind.ObjectWriter objectWriter) extends Record implements org.approvej.print.PrintFormat<T>, org.approvej.print.PrintFormatProvider<T>
A PrintFormat that uses ObjectWriter.writeValueAsString(Object) to print a value as YAML.
  • Constructor Details

    • YamlPrintFormat

      public YamlPrintFormat(tools.jackson.databind.ObjectWriter objectWriter)
      Creates a YamlPrintFormat using the given ObjectWriter.
      Parameters:
      objectWriter - the ObjectWriter that will be used for printing
    • 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>
    • alias

      public String alias()
      Specified by:
      alias in interface org.approvej.configuration.Provider<T>
    • create

      public org.approvej.print.PrintFormat<T> create()
      Specified by:
      create in interface org.approvej.configuration.Provider<T>
    • yaml

      public static <T> YamlPrintFormat<T> yaml(tools.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(tools.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:
      • YAMLMapper.Builder.build()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • objectWriter

      public tools.jackson.databind.ObjectWriter objectWriter()
      Returns the value of the objectWriter record component.
      Returns:
      the value of the objectWriter record component