Package com.atlassian.bamboo.specs.yaml
Class BambooYamlParserUtils
java.lang.Object
com.atlassian.bamboo.specs.yaml.BambooYamlParserUtils
Utilities for parsing the Bamboo YAML definition.
- See Also:
-
BambooYamlParser
BambooYamlDefinition
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Node
asNode
(@Nullable Object obj, @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext) Transforms object generated by snakeyaml into aNode
structure.static <T> @NotNull List<T>
checkListNotEmpty
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable List<T> list) Checks that a list is not empty.checkListType
(@NotNull List<? extends Node> list, @NotNull Class<T> expectedType) Check that all elements of the given list are of expected type.checkMapType
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @NotNull Map<?, ?> value) static <K,
V> @NotNull Map<K, V> checkMapType
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @NotNull Map<?, ?> value, @NotNull Class<K> expectedKeyType, @NotNull Class<V> expectedValueType) Checks that all keys and values of a map are of expected types.static <T> T
checkPresent
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @NotNull Optional<T> value) Check that the given optional is present.static <T> T
checkRequired
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, T value) Check that the given value is not null.static @NotNull String
checkStringNotBlank
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable String value) Checks that a string is not blank.static <T> T
checkType
(@NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable Object value, @NotNull Class<T> expectedType) Check that the given value is of expected type.static <T extends Node>
TCheck that the given node is of expected type.
-
Field Details
-
CFG_VERSION
Config constant to define YAML format version in each YAML document. -
CFG_SERVER_NAME
-
VARIABLES_CTX
- See Also:
-
-
Method Details
-
asNode
@NotNull public static @NotNull Node asNode(@Nullable @Nullable Object obj, @NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext) Transforms object generated by snakeyaml into aNode
structure.This method will cast the property to a string if it's a scalar (non-collection), e.g.
Integer
orBoolean
.- Parameters:
obj
- snakeyaml resultvalidationContext
- root validation context- Returns:
Node
structure
-
checkRequired
@Contract("_, null -> fail; _, !null -> !null") public static <T> T checkRequired(@NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable T value) Check that the given value is not null.- Returns:
- the given value
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkPresent
@NotNull public static <T> T checkPresent(@NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @NotNull @NotNull Optional<T> value) Check that the given optional is present.- Returns:
- the given value
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkType
@NotNull public static <T> T checkType(@NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable @Nullable Object value, @NotNull @NotNull Class<T> expectedType) Check that the given value is of expected type.- Returns:
- the value cast to the expected type
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkType
@NotNull public static <T extends Node> T checkType(@NotNull @NotNull Node node, @NotNull @NotNull Class<T> expectedType) Check that the given node is of expected type.- Returns:
- the value cast to the expected type
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkListType
@NotNull public static <T extends Node> @NotNull List<T> checkListType(@NotNull @NotNull List<? extends Node> list, @NotNull @NotNull Class<T> expectedType) Check that all elements of the given list are of expected type.- Returns:
- a new list with all elements cast to the expected type
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkMapType
-
checkMapType
@NotNull public static <K,V> @NotNull Map<K,V> checkMapType(@NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @NotNull @NotNull Map<?, ?> value, @NotNull @NotNull Class<K> expectedKeyType, @NotNull @NotNull Class<V> expectedValueType) Checks that all keys and values of a map are of expected types.- Returns:
- a new map, with key and value types set as expected
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkStringNotBlank
@NotNull public static @NotNull String checkStringNotBlank(@NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable @Nullable String value) Checks that a string is not blank.- Returns:
- the passed string
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-
checkListNotEmpty
@NotNull public static <T> @NotNull List<T> checkListNotEmpty(@NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext, @Nullable @Nullable List<T> list) Checks that a list is not empty.- Returns:
- the passed list
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
- on check failure
-