Package com.axelor.ai.seed
Class Yamls
java.lang.Object
com.axelor.ai.seed.Yamls
Nested-YAML parse/dump plus typed accessors, for config-shaped seed files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic BigDecimaldecimalOrNull(Map<String, Object> map, String key) static StringDumps a map to block-style YAML; multi-line string values use literal block scalars.static <E extends Enum<E>>
EParses a scalar into an enum constant (case-insensitive), ordefaultValueif absent/unknown.static <E extends Enum<E>>
EenumOrNull(String value, Class<E> type) Parses a scalar into an enum constant (case-insensitive), ornullif absent/unknown.static intstatic IntegerParses a YAML document into a nested map; empty map if null/blank/not a mapping.parseStrict(String content) Parses a YAML document into a nested map, refusing one that does not parse, is not a mapping, or holds nothing — blank, or every line commented out: an empty map would read as a file that declares nothing, and replace what one declared.static voidPutsvalueunderkeyonly when it is non-null (for building export maps).static voidPutsvalueunderkeyonly when it is non-null and not blank.static voidrequireKeys(Map<?, ?> doc, String... keys) Refuses a document naming a key that is none of these: a key dropped unread, misspelled or left from an older format, could have been the one restricting what the file grants.static StringA file name for a record keyed by a free-text name.static Stringstatic StringThe scalars listed underkey, blanks dropped; a lone scalar is a list of one.
-
Method Details
-
parse
Parses a YAML document into a nested map; empty map if null/blank/not a mapping. -
parseStrict
Parses a YAML document into a nested map, refusing one that does not parse, is not a mapping, or holds nothing — blank, or every line commented out: an empty map would read as a file that declares nothing, and replace what one declared.- Throws:
IllegalArgumentException- when the document is malformed, empty or not a mapping
-
requireKeys
Refuses a document naming a key that is none of these: a key dropped unread, misspelled or left from an older format, could have been the one restricting what the file grants.- Throws:
IllegalArgumentException- naming the unknown keys
-
dump
Dumps a map to block-style YAML; multi-line string values use literal block scalars. -
str
-
str
-
enumOr
Parses a scalar into an enum constant (case-insensitive), ordefaultValueif absent/unknown. -
enumOrNull
Parses a scalar into an enum constant (case-insensitive), ornullif absent/unknown. -
intOrNull
-
intOr
-
bool
-
decimalOrNull
-
put
Putsvalueunderkeyonly when it is non-null (for building export maps). -
putIfNotBlank
Putsvalueunderkeyonly when it is non-null and not blank. -
strings
The scalars listed underkey, blanks dropped; a lone scalar is a list of one. -
slug
A file name for a record keyed by a free-text name. -
maps
-