java.lang.Object
io.github.astrapi69.yaml.ObjectToYamlExtensions
The class
ObjectToYamlExtensions converts java objects to yaml string objects-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> StringCreates from the givenLista yaml stringstatic <T> StringCreates from the givenLista yaml stringstatic <T> StringtoYaml(T object) Creates a yamlStringfrom the given argument objectstatic <T> StringtoYaml(T object, boolean newMapper) Creates a yamlStringfrom the given Objectstatic <T> StringtoYaml(T object, com.fasterxml.jackson.dataformat.yaml.YAMLMapper mapper) Creates a yamlStringfrom the given Object and the given object mapper
-
Method Details
-
toYaml
Creates from the givenLista yaml string- Type Parameters:
T- the generic type- Parameters:
list- the list- Returns:
- the yaml string.
- Throws:
IOException- Signals that an I/O exception has occurred.
-
toYaml
public static <T> String toYaml(List<T> list, com.fasterxml.jackson.dataformat.yaml.YAMLMapper mapper) throws IOException Creates from the givenLista yaml string- Type Parameters:
T- the generic type- Parameters:
list- the listmapper- the object mapper- Returns:
- the yaml string
- Throws:
IOException- Signals that an I/O exception has occurred
-
toYaml
Creates a yamlStringfrom the given argument object- Type Parameters:
T- the generic type of the given argument object- Parameters:
object- the object.- Returns:
- the json string.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If an error occurs when converting object to String
-
toYaml
public static <T> String toYaml(T object, boolean newMapper) throws com.fasterxml.jackson.core.JsonProcessingException Creates a yamlStringfrom the given Object- Type Parameters:
T- the generic type- Parameters:
object- the objectnewMapper- 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 string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If an error occurs when converting object to String
-
toYaml
public static <T> String toYaml(T object, com.fasterxml.jackson.dataformat.yaml.YAMLMapper mapper) throws com.fasterxml.jackson.core.JsonProcessingException Creates a yamlStringfrom the given Object and the given object mapper- Type Parameters:
T- the generic type- Parameters:
object- the objectmapper- the object mapper- Returns:
- the string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If an error occurs when converting object to String
-