public ComponentSpecification intersect(ComponentSpecification other) {
        if (!getName().equals(other.getName())) {
            throw new RuntimeException("The names of the component specifications does not match("
                    + getName() + "!=" + other.getName() + ").");
        }
        if (!namespaceMatch(other.getNamespace())) {
            throw new RuntimeException("The namespaces of the component specifications does not match("
                    + this + ", " + other +")");
        }

        return new ComponentSpecification(getName(),
                getVersionSpecification().intersect(other.getVersionSpecification()),
                getNamespace());
    }
Checks if a componentId matches a given spec
component/src/main/java/com/yahoo/component/ComponentSpecification.java