// Path: src/com/github/tinselspoon/intellij/kubernetes/ResourceTypeKey.java
// public class ResourceTypeKey {
// 
//     /** The value of the "apiVersion" field, e.g. {@code batch/v1}. */
//     private final String apiVersion;
// 
//     /** The value of the "kind" field, e.g. {@code Job}. */
//     private final String kind;
// 
//     /**
//      * Default constructor.
//      *
//      * @param apiVersion the value of the "apiVersion" field, e.g. {@code batch/v1}.
//      * @param kind the value of the "kind" field, e.g. {@code Job}.
//      */
//     public ResourceTypeKey(final String apiVersion, final String kind) {
//         this.apiVersion = apiVersion;
//         this.kind = kind;
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
//         final ResourceTypeKey that = (ResourceTypeKey) o;
//         return Objects.equals(apiVersion, that.apiVersion) && Objects.equals(kind, that.kind);
//     }
// 
//     /**
//      * Gets the value of the "apiVersion" field, e.g. {@code batch/v1}.
//      *
//      * @return the api version.
//      */
//     public String getApiVersion() {
//         return apiVersion;
//     }
// 
//     /**
//      * Gets the value of the "kind" field, e.g. {@code Job}.
//      *
//      * @return the kind.
//      */
//     public String getKind() {
//         return kind;
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(apiVersion, kind);
//     }
// }


import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.github.tinselspoon.intellij.kubernetes.ResourceTypeKey;
    @Nullable
    private SwaggerSpec getSpec(@NotNull final ResourceTypeKey resourceTypeKey) {
        final String apiVersion = resourceTypeKey.getApiVersion();
        final String modelId = modelIdFromResourceKey(resourceTypeKey);
        return getSpecs().stream().filter(s -> apiVersion.equals(s.getApiVersion()) && s.getModels().containsKey(modelId)).findAny().orElse(null);
    }

    /**
     * Get a set of loaded {@link SwaggerSpec}s, initialising if necessary.
     *
     * @return the swagger specs.
     */
    @NotNull
    private List<SwaggerSpec> getSpecs() {
        return modelLoader.getActiveSpecs();
    }

    /**
     * Generates the model ID from the specified {@link ResourceTypeKey}.
     * <p>
     * This is achieved by concatenating the "version" part (e.g. {@code v1} in {@code batch/v1}) of the resource key {@linkplain ResourceTypeKey#apiVersion API version}, a dot, and the {@linkplain
     * ResourceTypeKey#getKind() kind}.
     *
     * @param resourceTypeKey the resource type key.
     * @return the model ID.
     */
    @NotNull
    private String modelIdFromResourceKey(final ResourceTypeKey resourceTypeKey) {
        String resourceApiVersion = resourceTypeKey.getApiVersion();
        if (resourceApiVersion.indexOf('/') > -1) {
// Path: src/com/github/tinselspoon/intellij/kubernetes/ResourceTypeKey.java
// public class ResourceTypeKey {
// 
//     /** The value of the "apiVersion" field, e.g. {@code batch/v1}. */
//     private final String apiVersion;
// 
//     /** The value of the "kind" field, e.g. {@code Job}. */
//     private final String kind;
// 
//     /**
//      * Default constructor.
//      *
//      * @param apiVersion the value of the "apiVersion" field, e.g. {@code batch/v1}.
//      * @param kind the value of the "kind" field, e.g. {@code Job}.
//      */
//     public ResourceTypeKey(final String apiVersion, final String kind) {
//         this.apiVersion = apiVersion;
//         this.kind = kind;
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
//         final ResourceTypeKey that = (ResourceTypeKey) o;
//         return Objects.equals(apiVersion, that.apiVersion) && Objects.equals(kind, that.kind);
//     }
// 
//     /**
//      * Gets the value of the "apiVersion" field, e.g. {@code batch/v1}.
//      *
//      * @return the api version.
//      */
//     public String getApiVersion() {
//         return apiVersion;
//     }
// 
//     /**
//      * Gets the value of the "kind" field, e.g. {@code Job}.
//      *
//      * @return the kind.
//      */
//     public String getKind() {
//         return kind;
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(apiVersion, kind);
//     }
// }


// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ModelProvider.java
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.github.tinselspoon.intellij.kubernetes.ResourceTypeKey;

    @Nullable
    private SwaggerSpec getSpec(@NotNull final ResourceTypeKey resourceTypeKey) {
        final String apiVersion = resourceTypeKey.getApiVersion();
        final String modelId = modelIdFromResourceKey(resourceTypeKey);
        return getSpecs().stream().filter(s -> apiVersion.equals(s.getApiVersion()) && s.getModels().containsKey(modelId)).findAny().orElse(null);
    }

    /**
     * Get a set of loaded {@link SwaggerSpec}s, initialising if necessary.
     *
     * @return the swagger specs.
     */
    @NotNull
    private List<SwaggerSpec> getSpecs() {
        return modelLoader.getActiveSpecs();
    }

    /**
     * Generates the model ID from the specified {@link ResourceTypeKey}.
     * <p>
     * This is achieved by concatenating the "version" part (e.g. {@code v1} in {@code batch/v1}) of the resource key {@linkplain ResourceTypeKey#apiVersion API version}, a dot, and the {@linkplain
     * ResourceTypeKey#getKind() kind}.
     *
     * @param resourceTypeKey the resource type key.
     * @return the model ID.
     */
    @NotNull
    private String modelIdFromResourceKey(final ResourceTypeKey resourceTypeKey) {
        String resourceApiVersion = resourceTypeKey.getApiVersion();
        if (resourceApiVersion.indexOf('/') > -1) {
            resourceApiVersion = resourceApiVersion.substring(resourceApiVersion.indexOf('/') + 1);