Package io.github.astrapi69.yaml
Class YamlFileToObjectExtensions
- java.lang.Object
-
- io.github.astrapi69.yaml.YamlFileToObjectExtensions
-
public final class YamlFileToObjectExtensions extends java.lang.ObjectThe classYamlFileToObjectExtensionsconverts yaml strings to java object and java collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
java.util.Map<K,V>toMapObject(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<java.util.Map<K,V>> typeReference)Transforms the given yaml file into a java map objectstatic <K,V>
java.util.Map<K,V>toMapObject(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<java.util.Map<K,V>> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper)Transforms the given yaml file into a java map objectstatic <T> TtoObject(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper)Transforms the given yaml file into a java object.static <T> TtoObject(java.io.File yamlFile, java.lang.Class<T> clazz)Transforms the given yaml file into a java object.static <T> TtoObject(java.io.File yamlFile, java.lang.Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper)Transforms the given yaml file into a java object.static <T> java.util.Collection<T>toObjectCollection(java.io.File yamlFile, java.lang.Class<? extends java.util.Collection> collectionClass, java.lang.Class<T> elementClass)Transforms the given yaml file into a java objectCollectionstatic <T> java.util.List<T>toObjectList(java.io.File yamlFile, java.lang.Class<T> elementClass)Transforms the given yaml string into a java objectList
-
-
-
Method Detail
-
toMapObject
public static <K,V> java.util.Map<K,V> toMapObject(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<java.util.Map<K,V>> typeReference) throws java.io.IOExceptionTransforms the given yaml file into a java map object- Type Parameters:
K- the generic type of keysV- the generic type of values- Parameters:
yamlFile- the yaml filetypeReference- the type reference- Returns:
- the t
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toMapObject
public static <K,V> java.util.Map<K,V> toMapObject(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<java.util.Map<K,V>> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOExceptionTransforms the given yaml file into a java map object- Type Parameters:
K- the generic type of keysV- the generic type of values- Parameters:
yamlFile- the yaml filetypeReference- the type referencemapper- the object mapper- Returns:
- the t
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObject
public static <T> T toObject(java.io.File yamlFile, java.lang.Class<T> clazz) throws java.io.IOExceptionTransforms the given yaml file into a java object.- Type Parameters:
T- the generic type- Parameters:
yamlFile- the yaml fileclazz- the clazz- Returns:
- the t
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObject
public static <T> T toObject(java.io.File yamlFile, java.lang.Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOExceptionTransforms the given yaml file into a java object.- Type Parameters:
T- the generic type- Parameters:
yamlFile- the yaml fileclazz- the clazzmapper- the mapper- Returns:
- the t
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObject
public static <T> T toObject(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOExceptionTransforms the given yaml file into a java object.- Type Parameters:
T- the generic type- Parameters:
yamlFile- the yaml filetypeReference- the type referencemapper- the mapper- Returns:
- the t
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObjectCollection
public static <T> java.util.Collection<T> toObjectCollection(java.io.File yamlFile, java.lang.Class<? extends java.util.Collection> collectionClass, java.lang.Class<T> elementClass) throws java.io.IOExceptionTransforms the given yaml file into a java objectCollection- Type Parameters:
T- the generic type of the return type- Parameters:
yamlFile- the yaml filecollectionClass- the collection classelementClass- the element class- Returns:
- the list with the java objects.
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObjectList
public static <T> java.util.List<T> toObjectList(java.io.File yamlFile, java.lang.Class<T> elementClass) throws java.io.IOExceptionTransforms the given yaml string into a java objectList- Type Parameters:
T- the generic type of the return type- Parameters:
yamlFile- the yaml fileelementClass- the element class of the generic type- Returns:
- the list with the java objects
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
-