<commit_before>package de.nenick.espressomacchiato.matchers;

import android.support.test.espresso.core.deps.guava.collect.Lists;
import android.support.test.espresso.matcher.ViewMatchers;
import android.view.View;

import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;

import de.nenick.espressomacchiato.elements.EspView;

public abstract class EspAllOfBuilder<ElementT extends EspView> {

    protected ArrayList<Matcher<? super View>> matcher = Lists.newArrayList();

    public EspAllOfBuilder<ElementT> withId(int resourceId) {
        matcher.add(ViewMatchers.withId(resourceId));
        return this;
    }

    public EspAllOfBuilder<ElementT> withIsDisplayed() {
        matcher.add(ViewMatchers.isDisplayed());
        return this;
    }

    public EspAllOfBuilder<ElementT> withParentInHierarchy(int resourceId) {
        matcher.add(ViewMatchers.isDescendantOfA(ViewMatchers.withId(resourceId)));
        return this;
    }

    public ElementT build() {
        try {
            Matcher<View> allOfMatcher = Matchers.allOf(matcher);
            return getGenericClass().getConstructor(Matcher.class).newInstance(allOfMatcher);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }

    protected Class<ElementT> getGenericClass() {
        Type genericSuperclass = getClass().getGenericSuperclass();
        if (genericSuperclass instanceof ParameterizedType) {
            //noinspection unchecked
            return ((Class) ((ParameterizedType) genericSuperclass).getActualTypeArguments()[0]);
        } else {
            throw new IllegalArgumentException("Please provide generic element");
        }
    }
}<commit_msg>add withVisibility and withText matcher to EspAllOfBuilder<commit_after>package de.nenick.espressomacchiato.matchers;

import android.support.test.espresso.core.deps.guava.collect.Lists;
import android.support.test.espresso.matcher.ViewMatchers;
import android.view.View;

import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;

import de.nenick.espressomacchiato.elements.EspView;

public abstract class EspAllOfBuilder<ElementT extends EspView> {

    protected ArrayList<Matcher<? super View>> matcher = Lists.newArrayList();

    public EspAllOfBuilder<ElementT> withId(int resourceId) {
        matcher.add(ViewMatchers.withId(resourceId));
        return this;
    }

    public EspAllOfBuilder<ElementT> withIsDisplayed() {
        matcher.add(ViewMatchers.isDisplayed());
        return this;
    }

    public EspAllOfBuilder<ElementT> withParentInHierarchy(int resourceId) {
        matcher.add(ViewMatchers.isDescendantOfA(ViewMatchers.withId(resourceId)));
        return this;
    }

    public EspAllOfBuilder<ElementT> withText(String text) {
        matcher.add(ViewMatchers.withText(text));
        return this;
    }

    public EspAllOfBuilder<ElementT> withVisibility(ViewMatchers.Visibility visible) {
        matcher.add(ViewMatchers.withEffectiveVisibility(visible));
        return this;
    }

    public ElementT build() {
        try {
            Matcher<View> allOfMatcher = Matchers.allOf(matcher);
            return getGenericClass().getConstructor(Matcher.class).newInstance(allOfMatcher);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }

    protected Class<ElementT> getGenericClass() {
        Type genericSuperclass = getClass().getGenericSuperclass();
        if (genericSuperclass instanceof ParameterizedType) {
            //noinspection unchecked
            return ((Class) ((ParameterizedType) genericSuperclass).getActualTypeArguments()[0]);
        } else {
            throw new IllegalArgumentException("Please provide generic element");
        }
    }
}
{'fraction_non_alphanumeric': 0.09643128321943811, 'fraction_numerical': 0.0005062009617818274, 'mean_word_length': 3.5635103926097, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '2897685', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1105, 'n_words': 200}