<commit_before>package com.googlecode.totallylazy.matchers;

import com.googlecode.totallylazy.Objects;
import com.googlecode.totallylazy.Sequence;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

import java.util.Iterator;

import static com.googlecode.totallylazy.Sequences.sequence;

@SuppressWarnings("unchecked")
public class IterableMatcher<T> extends TypeSafeMatcher<Iterable<T>> {
    private final Sequence<T> expected;
    private boolean shouldBeSameSize;

    private IterableMatcher(Sequence<T> expected, boolean shouldBeSameSize) {
        this.expected = expected;
        this.shouldBeSameSize = shouldBeSameSize;
    }

    public static Matcher<Iterable> hasSize(final Number size) {
        return new HasSizeMatcher(size);
    }

    public static <T> Matcher<Iterable<T>> isEmpty(Class<T> aClass) {
        return IterableMatcher.<T>isEmpty();
    }

    public static <T> Matcher<Iterable<T>> isEmpty() {
        return IterableMatcher.<T>hasExactly();
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first) {
        return hasExactly(sequence(first));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second) {
        return hasExactly(sequence(first, second));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second, final T third) {
        return hasExactly(sequence(first, second, third));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second, final T third, final T fourth) {
        return hasExactly(sequence(first, second, third, fourth));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second, final T third, final T fourth, final T fifth) {
        return hasExactly(sequence(first, second, third, fourth, fifth));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T... items) {
        return hasExactly(sequence(items));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(Sequence<T> expected) {
        return new IterableMatcher<T>(expected, true);
    }

    public static <T> Matcher<Iterable<T>> startsWith(T... items) {
        return startsWith(sequence(items));
    }

    public static <T> Matcher<Iterable<T>> startsWith(Sequence<T> expected) {
        return new IterableMatcher<T>(expected, false);
    }

    @Override
    public boolean matchesSafely(Iterable<T> actual) {
        Iterator<T> e = this.expected.iterator();
        Iterator<T> a = actual.iterator();
        while(e.hasNext()){
            if(!a.hasNext()){
                return false;
            }

            if(!Objects.equalTo(e.next(), a.next())){
                return false;
            }
        }
        if(shouldBeSameSize && a.hasNext()){
            return false;
        }
        return true;
    }

    public void describeTo(Description description) {
        description.appendValue(expected);
    }

}
<commit_msg>Reduced scope of suppression<commit_after>package com.googlecode.totallylazy.matchers;

import com.googlecode.totallylazy.Objects;
import com.googlecode.totallylazy.Sequence;
import com.googlecode.totallylazy.Sequences;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

import java.util.Iterator;

import static com.googlecode.totallylazy.Sequences.sequence;

public class IterableMatcher<T> extends TypeSafeMatcher<Iterable<T>> {
    private final Sequence<T> expected;
    private boolean shouldBeSameSize;

    private IterableMatcher(Sequence<T> expected, boolean shouldBeSameSize) {
        this.expected = expected;
        this.shouldBeSameSize = shouldBeSameSize;
    }

    @SuppressWarnings("unchecked")
    public static Matcher<Iterable> hasSize(final Number size) {
        return new HasSizeMatcher(size);
    }

    public static <T> Matcher<Iterable<T>> isEmpty(Class<T> aClass) {
        return IterableMatcher.<T>isEmpty();
    }

    public static <T> Matcher<Iterable<T>> isEmpty() {
        return IterableMatcher.<T>hasExactly(Sequences.<T>empty());
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first) {
        return hasExactly(sequence(first));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second) {
        return hasExactly(sequence(first, second));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second, final T third) {
        return hasExactly(sequence(first, second, third));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second, final T third, final T fourth) {
        return hasExactly(sequence(first, second, third, fourth));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T first, final T second, final T third, final T fourth, final T fifth) {
        return hasExactly(sequence(first, second, third, fourth, fifth));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(final T... items) {
        return hasExactly(sequence(items));
    }

    public static <T> Matcher<Iterable<T>> hasExactly(Sequence<T> expected) {
        return new IterableMatcher<T>(expected, true);
    }

    public static <T> Matcher<Iterable<T>> startsWith(T... items) {
        return startsWith(sequence(items));
    }

    public static <T> Matcher<Iterable<T>> startsWith(Sequence<T> expected) {
        return new IterableMatcher<T>(expected, false);
    }

    @Override
    public boolean matchesSafely(Iterable<T> actual) {
        Iterator<T> e = this.expected.iterator();
        Iterator<T> a = actual.iterator();
        while(e.hasNext()){
            if(!a.hasNext()){
                return false;
            }

            if(!Objects.equalTo(e.next(), a.next())){
                return false;
            }
        }
        if(shouldBeSameSize && a.hasNext()){
            return false;
        }
        return true;
    }

    public void describeTo(Description description) {
        description.appendValue(expected);
    }

}

{'fraction_non_alphanumeric': 0.11489151873767259, 'fraction_numerical': 0.0, 'mean_word_length': 3.196551724137931, 'pattern_counts': {'":': 0, '<': 102, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4439753', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1767, 'n_words': 435}