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

com.xliic.openapi.bundler.JsonPath Maven / Gradle / Ivy

Go to download

Bundles multiple OpenAPI files (in JSON or YAML formats) using external references into one JSON file.

There is a newer version: 4.0
Show newest version
/*
 Copyright (c) 42Crunch Ltd. All rights reserved.
 Licensed under the GNU Affero General Public License version 3. See LICENSE.txt in the project root for license information.
*/

package com.xliic.openapi.bundler;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("serial")
public class JsonPath extends ArrayList {
    public JsonPath(String... keys) {
        super();
        for (String key : keys) {
            add(key);
        }
    }

    public JsonPath(List keys) {
        super(keys);
    }

    public JsonPath(JsonPath path) {
        super(path);
    }

    JsonPath withKeys(List keys) {
        JsonPath copy = new JsonPath(this);
        copy.addAll(keys);
        return copy;
    }

    JsonPath withKey(String key) {
        JsonPath copy = new JsonPath(this);
        copy.add(key);
        return copy;
    }

    public JsonPointer toPointer() {
        return JsonPointer.fromJsonPath(this);
    }

    public boolean isSubPathOf(JsonPath path) {
        if (path.size() > this.size()) {
            return false;
        }

        for (int i = 0; i < path.size(); i++) {
            if (!path.get(i).equals(this.get(i))) {
                return false;
            }
        }
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy