Class YamlOps
java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.DynamicOps<Object>
com.github.darksoulq.abyssallib.common.serialization.ops.YamlOps
An implementation of
DynamicOps using SnakeYAML.
This class treats the serialized format as a tree of standard Java objects (Maps, Lists, and Primitives), allowing for bidirectional conversion between Java POJOs and YAML data.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncreateBoolean(boolean value) createDouble(double value) createFloat(float value) createInt(int value) createList(List<Object> elements) Creates a YAML-compatible list.createLong(long value) Creates a YAML-compatible map.createString(String value) static StringSerializes a Java object structure into a YAML string.empty()getBooleanValue(Object input) getDoubleValue(Object input) getFloatValue(Object input) getIntValue(Object input) getLongValue(Object input) getStringValue(Object input) parse(InputStream in) Parses YAML data from an InputStream into a normalized Java object structure.Parses a YAML string into a normalized Java object structure.
-
Field Details
-
INSTANCE
The singleton instance of YamlOps.
-
-
Method Details
-
createString
- Specified by:
createStringin classDynamicOps<Object>- Parameters:
value- The string to wrap.- Returns:
- The raw string object.
-
createInt
- Specified by:
createIntin classDynamicOps<Object>- Parameters:
value- The integer to wrap.- Returns:
- The raw Integer object.
-
createLong
- Specified by:
createLongin classDynamicOps<Object>- Parameters:
value- The long to wrap.- Returns:
- The raw Long object.
-
createFloat
- Specified by:
createFloatin classDynamicOps<Object>- Parameters:
value- The float to wrap.- Returns:
- The raw Float object.
-
createDouble
- Specified by:
createDoublein classDynamicOps<Object>- Parameters:
value- The double to wrap.- Returns:
- The raw Double object.
-
createBoolean
- Specified by:
createBooleanin classDynamicOps<Object>- Parameters:
value- The boolean to wrap.- Returns:
- The raw Boolean object.
-
createList
Creates a YAML-compatible list.- Specified by:
createListin classDynamicOps<Object>- Parameters:
elements- The elements to include in the list.- Returns:
- A new
ArrayListcontaining the elements.
-
createMap
Creates a YAML-compatible map.- Specified by:
createMapin classDynamicOps<Object>- Parameters:
map- The map entries to include.- Returns:
- A new
LinkedHashMapto preserve entry order.
-
getStringValue
- Specified by:
getStringValuein classDynamicOps<Object>- Parameters:
input- The object to check.- Returns:
- An Optional containing the string if the input is a
String.
-
getIntValue
- Specified by:
getIntValuein classDynamicOps<Object>- Parameters:
input- The object to check.- Returns:
- An Optional containing the integer if the input is an
Integer.
-
getLongValue
- Specified by:
getLongValuein classDynamicOps<Object>- Parameters:
input- The object to check.- Returns:
- An Optional containing the long if the input is a
Long.
-
getFloatValue
- Specified by:
getFloatValuein classDynamicOps<Object>- Parameters:
input- The object to check.- Returns:
- An Optional containing the float if the input is a
Float.
-
getDoubleValue
- Specified by:
getDoubleValuein classDynamicOps<Object>- Parameters:
input- The object to check.- Returns:
- An Optional containing the double if the input is a
Double.
-
getBooleanValue
- Specified by:
getBooleanValuein classDynamicOps<Object>- Parameters:
input- The object to check.- Returns:
- An Optional containing the boolean if the input is a
Boolean.
-
getList
-
getMap
-
empty
- Specified by:
emptyin classDynamicOps<Object>- Returns:
- A
nullreference representing an empty YAML node.
-
parse
-
parse
Parses YAML data from an InputStream into a normalized Java object structure.- Parameters:
in- The input stream containing YAML data.- Returns:
- A normalized object.
-
dump
-