Class YamlStringToObjectExtensions

java.lang.Object
io.github.astrapi69.yaml.YamlStringToObjectExtensions

public final class YamlStringToObjectExtensions extends Object
The class YamlStringToObjectExtensions converts yaml strings to java object and java collections.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K, V> Map<K,V>
    toMapObject(String yamlString, com.fasterxml.jackson.core.type.TypeReference<Map<K,V>> typeReference)
    Transforms the given yaml string into a java map object
    static <K, V> Map<K,V>
    toMapObject(String yamlString, com.fasterxml.jackson.core.type.TypeReference<Map<K,V>> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper)
    Transforms the given yaml string into a java map object
    static <T> T
    toObject(String yamlString, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper)
    Transforms the given yaml string into a java object.
    static <T> T
    toObject(String yamlString, Class<T> clazz)
    Transforms the given yaml string into a java object.
    static <T> T
    toObject(String yamlString, Class<T> clazz, boolean newMapper)
    Transforms the given yaml string into a java object.
    static <T> T
    toObject(String yamlString, Class<T> clazz, com.fasterxml.jackson.databind.Module... modules)
    Transforms the given yaml string into a java object.
    static <T> T
    toObject(String yamlString, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper)
    Transforms the given yaml string into a java object.
    static <T> Collection<T>
    toObjectCollection(String yamlString, Class<? extends Collection> collectionClass, Class<T> elementClass)
    Transforms the given yaml string into a java object Collection
    static <T> List<T>
    toObjectList(String yamlString, Class<T> elementClass)
    Transforms the given yaml string into a java object List

    Methods inherited from class java.lang.Object

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

    • toMapObject

      public static <K, V> Map<K,V> toMapObject(String yamlString, com.fasterxml.jackson.core.type.TypeReference<Map<K,V>> typeReference) throws IOException
      Transforms the given yaml string into a java map object
      Type Parameters:
      K - the generic type of keys
      V - the generic type of values
      Parameters:
      yamlString - the yaml string
      typeReference - the type reference
      Returns:
      the t
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toMapObject

      public static <K, V> Map<K,V> toMapObject(String yamlString, com.fasterxml.jackson.core.type.TypeReference<Map<K,V>> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper) throws IOException
      Transforms the given yaml string into a java map object
      Type Parameters:
      K - the generic type of keys
      V - the generic type of values
      Parameters:
      yamlString - the yaml string
      typeReference - the type reference
      mapper - the object mapper
      Returns:
      the t
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toObject

      public static <T> T toObject(String yamlString, Class<T> clazz) throws IOException
      Transforms the given yaml string into a java object.
      Type Parameters:
      T - the generic type of the return type
      Parameters:
      yamlString - the yaml string
      clazz - the clazz of the generic type
      Returns:
      the object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toObject

      public static <T> T toObject(String yamlString, Class<T> clazz, boolean newMapper) throws IOException
      Transforms the given yaml string into a java object.
      Type Parameters:
      T - the generic type of the return type
      Parameters:
      yamlString - the yaml string
      clazz - the clazz of the generic type
      newMapper - flag that indicates if a new ObjectMapper should be created. if true a new ObjectMapper will be created otherwise the ObjectMapper from this class will be returned.
      Returns:
      the object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toObject

      public static <T> T toObject(String yamlString, Class<T> clazz, com.fasterxml.jackson.databind.Module... modules) throws IOException
      Transforms the given yaml string into a java object.
      Type Parameters:
      T - the generic type of the return type
      Parameters:
      yamlString - the yaml string
      clazz - the clazz of the generic type
      modules - The modules to register for the mapper
      Returns:
      the object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toObject

      public static <T> T toObject(String yamlString, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws IOException
      Transforms the given yaml string into a java object.
      Type Parameters:
      T - the generic type
      Parameters:
      yamlString - the yaml string
      clazz - the clazz of the generic type
      mapper - the object mapper
      Returns:
      the t
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toObject

      public static <T> T toObject(String yamlString, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper) throws IOException
      Transforms the given yaml string into a java object.
      Type Parameters:
      T - the generic type
      Parameters:
      yamlString - the yaml string
      typeReference - the type reference
      mapper - the object mapper
      Returns:
      the t
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toObjectCollection

      public static <T> Collection<T> toObjectCollection(String yamlString, Class<? extends Collection> collectionClass, Class<T> elementClass) throws IOException
      Transforms the given yaml string into a java object Collection
      Type Parameters:
      T - the generic type of the return type
      Parameters:
      yamlString - the yaml string
      collectionClass - the collection class
      elementClass - the element class
      Returns:
      the list with the java objects.
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toObjectList

      public static <T> List<T> toObjectList(String yamlString, Class<T> elementClass) throws IOException
      Transforms the given yaml string into a java object List
      Type Parameters:
      T - the generic type of the return type
      Parameters:
      yamlString - the yaml string
      elementClass - the element class of the generic type
      Returns:
      the list with the java objects
      Throws:
      IOException - Signals that an I/O exception has occurred.