Class YamlObject<T>

  • Direct Known Subclasses:
    YamlMap, YamlSeq

    public class YamlObject<T>
    extends Object
    Base class for Yaml object wrappers.

    Yaml is represented as atomic types (literals, expressions) and YamlObjects (for wrapping lists and maps). The factory method create(Object) will sort out the details. These YamlObjects are used to stage data when parsing a Yaml document.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected T raw
      underlying raw object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected YamlObject​(T raw)  
    • Field Detail

      • raw

        protected T raw
        underlying raw object
    • Constructor Detail

      • YamlObject

        protected YamlObject​(T raw)
    • Method Detail

      • create

        public static <W> YamlObject<W> create​(W raw)
        Convert raw object to Yaml wrapper.

        Other data (Literals, Expressions) are considered atomic and do not provide a YamlObject representation.
        Returns:
        Yaml object wrapper, or null if the provided raw object is null.
      • lookup

        public Object lookup​(String path)
        Raw value access via path.

        Indended for quick value lookup during test cases.

        • raw("1"): first value in a sequence
        • raw("x"): value for "x" in a map
        • raw("rules/2/symbolizers/3"): third symbolizer in second rule
        Returns:
        raw value, or null if not available
      • raw

        public T raw()
        Returns the raw object.
      • lookupY

        public Object lookupY​(String path)
        See lookup(java.lang.String). Ensures that the result is wrapped as a YamlObject if it is a map, list, or array.
      • convert

        protected <C> C convert​(Object obj,
                                Class<C> clazz)
        Converts an object to the specified class.
      • toString

        public String toString()
        Yaml representation.
        Overrides:
        toString in class Object
        Returns:
        Yaml representation