All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.relayr.java.model.models.schema.ArraySchema Maven / Gradle / Ivy

package io.relayr.java.model.models.schema;

import java.util.List;

public class ArraySchema extends ValueSchema {

    public ArraySchema(ValueSchema schema) {
        title = schema.title;
        description = schema.description;
        unit = schema.unit;
        schemaType = schema.schemaType;

        items = schema.items;
        maxItems = schema.maxItems;
        minItems = schema.minItems;
        uniqueItems = schema.uniqueItems;
        additionalItems = schema.additionalItems;
    }

    /** Items of this array MUST be objects, and each of these objects MUST be a valid JSON Schema. */
    public List getItems() {
        return items;
    }

    /** If defined this integer MUST be greater than, or equal to, 0. */
    public Integer getMaxItems() {
        return maxItems;
    }

    /** If defined this integer MUST be greater than, or equal to, 0. */
    public Integer getMinItems() {
        return minItems;
    }

    public boolean areItemsUnique() {
        return uniqueItems;
    }

    /** @return true if there can be any additional items in {@link #items} */
    public boolean containsAdditionalItems() {
        if (additionalItems == null) return false;

        if (additionalItems instanceof Boolean)
            return (boolean) additionalItems;

        return true;
    }

    @Override public boolean validate(Object value) {
        return validateNull(value);
    }
}