public CompoundName first(int n) {
        if (compounds.size() < n)
            throw new IllegalArgumentException("Asked for the first " + n + " components but '" +
                                               this + "' only have " + compounds.size() + " components.");
        if (compounds.size() == n) return this;
        if (compounds.isEmpty()) return empty;
        if (compounds.size() - 1 == n) return first;
        return first.first(n);
    }
Returns the first n components of this.

@throws IllegalArgumentException if this does not have at least n components
container-core/src/main/java/com/yahoo/processing/request/CompoundName.java