Package rs.jackson

Class YamlUtils

java.lang.Object
rs.jackson.YamlUtils

public class YamlUtils extends Object
YAML utils for mapping back and forth
Author:
ralph
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    fromYaml(File file, com.fasterxml.jackson.core.type.TypeReference<T> type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(File file, com.fasterxml.jackson.databind.JavaType type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(File file, Class<T> clazz)
    Convert from YAML to Object.
    static <T> T
    fromYaml(InputStream stream, com.fasterxml.jackson.core.type.TypeReference<T> type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(InputStream stream, com.fasterxml.jackson.databind.JavaType type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(InputStream stream, Class<T> clazz)
    Convert from YAML to Object.
    static <T> T
    fromYaml(Reader reader, com.fasterxml.jackson.core.type.TypeReference<T> type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(Reader reader, com.fasterxml.jackson.databind.JavaType type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(Reader reader, Class<T> clazz)
    Convert from YAML to Object.
    static <T> T
    fromYaml(String json, com.fasterxml.jackson.core.type.TypeReference<T> type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(String json, com.fasterxml.jackson.databind.JavaType type)
    Convert from YAML to Object.
    static <T> T
    fromYaml(String json, Class<T> clazz)
    Convert from YAML to Object.
    static com.fasterxml.jackson.databind.ObjectMapper
    Returns a configured JsonMapper object.
    static String
    Convert any object to its Json representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • YamlUtils

      public YamlUtils()
  • Method Details

    • toYaml

      public static String toYaml(Object o)
      Convert any object to its Json representation.
      Parameters:
      o - - the object to convert
      Returns:
      the YAML string
    • fromYaml

      public static <T> T fromYaml(String json, Class<T> clazz)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      json - YAML string
      clazz - Type Class
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(String json, com.fasterxml.jackson.databind.JavaType type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      json - YAML string
      type - Java type
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(String json, com.fasterxml.jackson.core.type.TypeReference<T> type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      json - YAML string
      type - Type reference
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(File file, Class<T> clazz)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      file - YAML file
      clazz - Type Class
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(File file, com.fasterxml.jackson.databind.JavaType type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      file - YAML file
      type - Java type
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(File file, com.fasterxml.jackson.core.type.TypeReference<T> type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      file - YAML file
      type - Type reference
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(InputStream stream, Class<T> clazz)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      stream - YAML input stream
      clazz - Type Class
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(InputStream stream, com.fasterxml.jackson.databind.JavaType type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      stream - YAML input stream
      type - Java type
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(InputStream stream, com.fasterxml.jackson.core.type.TypeReference<T> type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      stream - YAML input stream
      type - Type reference
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(Reader reader, Class<T> clazz)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      reader - YAML reader
      clazz - Type Class
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(Reader reader, com.fasterxml.jackson.databind.JavaType type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      reader - YAML reader
      type - Java type
      Returns:
      the object
    • fromYaml

      public static <T> T fromYaml(Reader reader, com.fasterxml.jackson.core.type.TypeReference<T> type)
      Convert from YAML to Object.
      Type Parameters:
      T - Class type
      Parameters:
      reader - YAML reader
      type - Type reference
      Returns:
      the object
    • getYamlMapper

      public static com.fasterxml.jackson.databind.ObjectMapper getYamlMapper()
      Returns a configured JsonMapper object.
      Returns:
      the JsonMapper