Class MapNode

java.lang.Object
com.atlassian.bamboo.specs.yaml.BaseNode
com.atlassian.bamboo.specs.yaml.MapNode
All Implemented Interfaces:
Node

public class MapNode extends BaseNode
Node representing a dictionary-like YAML structure.
  • Constructor Details

    • MapNode

      public MapNode(@NotNull @NotNull Map<String,?> structure, @NotNull @NotNull com.atlassian.bamboo.specs.api.validators.common.ValidationContext validationContext)
  • Method Details

    • getString

      @NotNull public @NotNull StringNode getString(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a 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.

    • getOptionalString

      @NotNull public @NotNull Optional<StringNode> getOptionalString(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a 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.

    • getOptionalBoolean

      @NotNull public @NotNull Optional<BooleanNode> getOptionalBoolean(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a Boolean, if the property is present. Throws if the property is defined but is of wrong type.

      Note: Strings that are not boolean literals are not accepted.

    • getList

      @NotNull public <T extends Node> @NotNull ListNode<T> getList(@NotNull @NotNull String property, @NotNull @NotNull Class<T> expectedType)
      Get a property from a parsed YAML as a 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.

    • getOptionalList

      @NotNull public <T extends Node> @NotNull Optional<ListNode<T>> getOptionalList(@NotNull @NotNull String property, @NotNull @NotNull Class<T> expectedType)
      Get a property from a parsed YAML as a 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.

    • getMap

      @NotNull public @NotNull MapNode getMap(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a 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.

    • getOptionalMap

      @NotNull public @NotNull Optional<MapNode> getOptionalMap(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a 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.

    • getNode

      @NotNull public @NotNull Node getNode(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a generic Node. Throws if property is not defined.
    • getOptionalNode

      @NotNull public @NotNull Optional<Node> getOptionalNode(@NotNull @NotNull String property)
      Get a property from a parsed YAML as a generic Node if it's present. Does not throw if the property is not defined.
    • getUnusedProperties

      @NotNull public @NotNull List<String> getUnusedProperties()
      Description copied from interface: Node
      Visits recursively the whole structure and returns list of unused properties. Children of unused properties are not reported.
    • getProperties

      @NotNull public @NotNull Collection<String> getProperties()