class VariantListBuilderImpl extends VariantListBuilder {

    @Override
    public VariantListBuilder add() {
        checkState(!(mediaTypes.isEmpty() && languages.isEmpty() && encodings.isEmpty()),
                   "At least one media type, language or encoding must be set");

        if (variants == null) {
            variants = new ArrayList<>();
        }

        Iterator<MediaType> mediaTypesIterator = mediaTypes.iterator();
        do {
            MediaType mediaType = mediaTypesIterator.hasNext() ? mediaTypesIterator.next() : null;
            Iterator<Locale> languagesIterator = languages.iterator();
            do {
                Locale language = languagesIterator.hasNext() ? languagesIterator.next() : null;
                Iterator<String> encodingsIterator = encodings.iterator();
                do {
                    String encoding = encodingsIterator.hasNext() ? encodingsIterator.next() : null;
                    variants.add(new Variant(mediaType, language, encoding));
                } while (encodingsIterator.hasNext());
            } while (languagesIterator.hasNext());
        } while (mediaTypesIterator.hasNext());

        clearAll();
        return this;
    }

    public  VariantListBuilderImpl();

}