Class Bucket


  • public class Bucket
    extends java.lang.Object
    wraps the properties Map of a json/yaml object and its location in the source document.
    • Constructor Summary

      Constructors 
      Constructor Description
      Bucket​(Scope scope, JsonPointer location, java.util.Map<java.lang.String,​java.lang.Object> properties)
      create an object bucket with scope & location in the source document and its properties.
      Bucket​(Scope scope, java.lang.String location, java.util.Map<java.lang.String,​java.lang.Object> properties)
      create an object bucket with the object location in the source document and its properties.
      Bucket​(Scope scope, java.util.Map<java.lang.String,​java.lang.Object> properties)
      create a document "root" bucket with an empty location.
    • Constructor Detail

      • Bucket

        public Bucket​(Scope scope,
                      java.util.Map<java.lang.String,​java.lang.Object> properties)
        create a document "root" bucket with an empty location.
        Parameters:
        scope - the scope of the document
        properties - the document properties
      • Bucket

        public Bucket​(Scope scope,
                      JsonPointer location,
                      java.util.Map<java.lang.String,​java.lang.Object> properties)
        create an object bucket with scope & location in the source document and its properties.
        Parameters:
        scope - the scope of the bucket
        location - the location (json pointer) inside source
        properties - the document properties
      • Bucket

        public Bucket​(Scope scope,
                      java.lang.String location,
                      java.util.Map<java.lang.String,​java.lang.Object> properties)
        create an object bucket with the object location in the source document and its properties.
        Parameters:
        scope - the document scope
        location - the location (json pointer) inside source
        properties - the document properties
    • Method Detail

      • empty

        public static Bucket empty()
      • createBucket

        public static @Nullable Bucket createBucket​(Scope scope,
                                                    @Nullable java.lang.Object source)
      • createBucket

        public static @Nullable Bucket createBucket​(Scope scope,
                                                    @Nullable java.lang.Object source,
                                                    JsonPointer location)
      • createBucket

        public static Bucket createBucket​(Scope scope,
                                          java.util.Map<java.lang.String,​java.lang.Object> source)
      • getScope

        public Scope getScope()
        the scope of this bucket.
        Returns:
        the document URI
      • getBaseUri

        public java.net.URI getBaseUri()
      • hasId

        public boolean hasId()
      • getId

        public @Nullable java.net.URI getId()
      • getLocation

        public JsonPointer getLocation()
        the location of this bucket in the source document.
        Returns:
        the location
      • convert

        public <T> @Nullable T convert​(java.lang.String property,
                                       PropertyConverter<T> converter)
        convert the property value to the expected type.
        Type Parameters:
        T - target type
        Parameters:
        property - property name
        converter - property converter
        Returns:
        a T object or null
      • convert

        public <T> @Nullable T convert​(PropertiesConverter<T> converter)
        convert "this" bucket to the expected type.
        Type Parameters:
        T - target type
        Parameters:
        converter - properties converter
        Returns:
        a T object or null
      • getBucket

        public @Nullable Bucket getBucket​(java.lang.String property)
        get property value as a Bucket. Throws if the property value is not an object properties Map.
        Parameters:
        property - property name
        Returns:
        child bucket
      • getRawValue

        public @Nullable java.lang.Object getRawValue​(java.lang.String property)
        get the raw value of the given property.
        Parameters:
        property - property name
        Returns:
        property value or null if the property does not exist
      • getRawValues

        public java.util.Map<java.lang.String,​java.lang.Object> getRawValues()
        get the raw value, i.e. the property map, of the bucket.
        Returns:
        the property map
      • hasProperty

        public boolean hasProperty​(java.lang.String property)
        checks if properties contains the given property name.
        Parameters:
        property - property name
        Returns:
        true if the property exists, else false
      • getProperty

        public @Nullable java.lang.Object getProperty​(java.lang.String property)
      • getRawValue

        public @Nullable RawValue getRawValue​(JsonPointer pointer)
        get the raw value with scope at the given property pointer position.
        Parameters:
        pointer - property location
        Returns:
        raw value or null if the property does not exist
      • getRawValueValue

        public @Nullable java.lang.Object getRawValueValue​(JsonPointer pointer)
      • walkPropertyTree

        @Deprecated
        public void walkPropertyTree​(java.lang.String property,
                                     BucketVisitor handler)
        Deprecated.
        walks the object tree of the given property and runs the handler on each child Bucket. It walks into any child map or collection of the property.
        Parameters:
        property - property name
        handler - node handler
      • forEach

        public void forEach​(java.util.function.BiConsumer<java.lang.String,​java.lang.Object> action)
      • forEachProperty

        public void forEachProperty​(java.util.function.Consumer<java.lang.String> action)