Constructor and Description |
---|
MapNode(Map<String,Object> structure,
com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext) |
Modifier and Type | Method and Description |
---|---|
<T extends Node> |
getList(String property,
Class<T> expectedType)
Get a property from a parsed YAML as a
List of a particular type. |
MapNode |
getMap(String property)
Get a property from a parsed YAML as a
Map . |
Node |
getNode(String property)
Get a property from a parsed YAML as a generic
Node . |
<T extends Node> |
getOptionalList(String property,
Class<T> expectedType)
Get a property from a parsed YAML as a
List of a particular type, if the property is present. |
Optional<MapNode> |
getOptionalMap(String property)
Get a property from a parsed YAML as a
Map if it's present. |
Optional<Node> |
getOptionalNode(String property)
Get a property from a parsed YAML as a generic
Node if it's present. |
Optional<StringNode> |
getOptionalString(String property)
Get a property from a parsed YAML as a
String , if the property is present. |
Collection<String> |
getProperties() |
StringNode |
getString(String property)
Get a property from a parsed YAML as a
String . |
List<String> |
getUnusedProperties()
Visits recursively the whole structure and returns list of unused properties.
|
getValidationContext, toString
@NotNull public StringNode getString(@NotNull String property)
String
. Throws if the property is not defined or if it's of wrong
type. This method will cast the property to a string if it's a scalar (non-collection), e.g. Integer
or
Boolean
.
Note: blank strings are not accepted. This method will throw if the property is defined but is blank.
@NotNull public Optional<StringNode> getOptionalString(@NotNull String property)
String
, if the property is present. Throws if the property is
defined but is of wrong type.
Note: blank strings are not accepted. This method will throw if the property is defined but is blank. If a property is optional, it should be skipped instead.
@NotNull public <T extends Node> ListNode<T> getList(@NotNull String property, @NotNull Class<T> expectedType)
List
of a particular type. Throws if the property is not defined,
is of wrong type, or if any element from the list is of wrong type.
Note: this method will throw if the list is empty! The intention is to use this method for lists which are required, and need to contain at least one element.
@NotNull public <T extends Node> Optional<ListNode<T>> getOptionalList(@NotNull String property, @NotNull Class<T> expectedType)
List
of a particular type, if the property is present.
Throws if the property is defined but is of wrong type, or if any element from the list is of wrong type.
Note: this method will not throw if the list is empty. The intention is to use this method for lists which are optional. Skipped properties and properties defining empty lists should be treated as equal.
@NotNull public MapNode getMap(@NotNull String property)
Map
. Throws if the property is not defined, is of wrong type, or
if any key or value is of wrong type.
Note: this method will not throw if the map is empty. It's not possible to tell which keys are meaningful and which are ignorable. Additional validation is necessary for the produced map.
@NotNull public Optional<MapNode> getOptionalMap(@NotNull String property)
Map
if it's present. Throws if the property is defined but is of
wrong type, or if any key or value is of wrong type.
Note: this method will not throw if the map is empty.
@NotNull public Node getNode(@NotNull String property)
Node
. Throws if property is not defined.@NotNull public Optional<Node> getOptionalNode(@NotNull String property)
Node
if it's present. Does not throw if the property
is not defined.@NotNull public List<String> getUnusedProperties()
Node
@NotNull public Collection<String> getProperties()
Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.