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

org.raml.ramltopojo.Utils Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package org.raml.ramltopojo;

import org.raml.v2.api.model.v10.api.Library;
import org.raml.v2.api.model.v10.datamodel.TypeDeclaration;

import java.util.List;
import java.util.Set;

/**
 * Created. There, you have it.
 */
public class Utils {

    public static Class declarationType(TypeDeclaration typeDeclaration) {

        return typeDeclaration.getClass().getInterfaces()[0];
    }

    static List goThroughLibraries(List foundTypes, Set visitedLibraries, List libraries) {


        for (Library library : libraries) {
            if (visitedLibraries.contains(library.name())) {

                continue;
            } else {

                visitedLibraries.add(library.name());
            }

            goThroughLibraries(foundTypes, visitedLibraries, library.uses());

            foundTypes.addAll(library.types());
        }

        return foundTypes;
    }

    static public  List allParents(TypeDeclaration target, List found) {

        found.add(target);
        for (TypeDeclaration typeDeclaration : target.parentTypes()) {
            allParents(typeDeclaration, found);
        }

        return found;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy