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

io.openapiprocessor.jsonschema.schema.JsonDependency Maven / Gradle / Ivy

There is a newer version: 2024.4
Show newest version
/*
 * Copyright 2022 https://github.com/openapi-processor/openapi-parser
 * PDX-License-Identifier: Apache-2.0
 */

package io.openapiprocessor.jsonschema.schema;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Collection;

import static io.openapiprocessor.jsonschema.support.Null.nonNull;

/**
 * handles json schema dependency which may be a schema or an array of string.
 */
@SuppressWarnings ("NullableProblems")
public class JsonDependency {
    private enum Kind {SCHEMA, ARRAY}

    private final Kind kind;
    private final @Nullable JsonSchema schema;
    private final @Nullable Collection properties;

    public JsonDependency (JsonSchema schema) {
        this.kind = Kind.SCHEMA;
        this.schema = schema;
        this.properties = null;
    }

    public JsonDependency (Collection values) {
        this.kind = Kind.ARRAY;
        this.schema = null;
        this.properties = values;
    }

    public boolean isSchema () {
        return kind == Kind.SCHEMA;
    }

    public JsonSchema getSchema () {
        return nonNull(schema);
    }

    public Collection getProperties () {
        return nonNull(properties);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy