Record Class YamlPrintFormat<T>

java.lang.Object
java.lang.Record
org.approvej.yaml.jackson.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>(com.fasterxml.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.
  • Field Summary

    Fields inherited from interface org.approvej.print.PrintFormat

    DEFAULT_FILENAME_EXTENSION
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor to be used in Configuration.
    YamlPrintFormat(com.fasterxml.jackson.databind.ObjectWriter objectWriter)
    Creates a YamlPrintFormat using the given ObjectWriter.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    org.approvej.print.PrintFormat<T>
     
    final boolean
    Indicates whether some other object is "equal to" this one.
     
    final int
    Returns a hash code value for this object.
    com.fasterxml.jackson.databind.ObjectWriter
    Returns the value of the objectWriter record component.
    org.approvej.print.Printer<T>
     
    final String
    Returns a string representation of this record class.
    static <T> YamlPrintFormat<T>
    Creates a YamlPrintFormat using the default YAMLMapper.
    static <T> YamlPrintFormat<T>
    yaml(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    Creates a YamlPrintFormat using the given ObjectMapper.
    static <T> YamlPrintFormat<T>
    yaml(com.fasterxml.jackson.databind.ObjectWriter objectWriter)
    Creates a YamlPrintFormat using the given ObjectWriter.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.approvej.print.PrintFormatProvider

    type
  • Constructor Details

    • YamlPrintFormat

      public YamlPrintFormat(com.fasterxml.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(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.writer()
    • 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()
    • 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 com.fasterxml.jackson.databind.ObjectWriter objectWriter()
      Returns the value of the objectWriter record component.
      Returns:
      the value of the objectWriter record component