Class Bucket
- java.lang.Object
-
- io.openapiprocessor.jsonschema.schema.Bucket
-
public class Bucket extends java.lang.Objectwraps the propertiesMapof 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> @Nullable Tconvert(PropertiesConverter<T> converter)convert "this" bucket to the expected type.<T> @Nullable Tconvert(java.lang.String property, PropertyConverter<T> converter)convert the property value to the expected type.static @Nullable BucketcreateBucket(Scope scope, @Nullable java.lang.Object source)static @Nullable BucketcreateBucket(Scope scope, @Nullable java.lang.Object source, JsonPointer location)static BucketcreateBucket(Scope scope, java.util.Map<java.lang.String,java.lang.Object> source)static Bucketempty()voidforEach(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)voidforEachProperty(java.util.function.Consumer<java.lang.String> action)java.net.URIgetBaseUri()@Nullable BucketgetBucket(java.lang.String property)get property value as aBucket.@Nullable java.net.URIgetId()JsonPointergetLocation()the location of this bucket in thesourcedocument.@Nullable java.lang.ObjectgetProperty(java.lang.String property)@Nullable RawValuegetRawValue(JsonPointer pointer)get the raw value with scope at the given property pointer position.@Nullable java.lang.ObjectgetRawValue(java.lang.String property)get the raw value of the given property.java.util.Map<java.lang.String,java.lang.Object>getRawValues()get the raw value, i.e.@Nullable java.lang.ObjectgetRawValueValue(JsonPointer pointer)ScopegetScope()the scope of this bucket.booleanhasId()booleanhasProperty(java.lang.String property)checks if properties contains the given property name.voidwalkPropertyTree(java.lang.String property, BucketVisitor handler)Deprecated.
-
-
-
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 documentproperties- 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 bucketlocation- the location (json pointer) insidesourceproperties- 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 scopelocation- the location (json pointer) insidesourceproperties- 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 thesourcedocument.- 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 nameconverter- property converter- Returns:
- a
Tobject 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
Tobject or null
-
getBucket
public @Nullable Bucket getBucket(java.lang.String property)
get property value as aBucket. Throws if the property value is not an object propertiesMap.- 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 childBucket. It walks into any child map or collection of the property.- Parameters:
property- property namehandler- 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)
-
-