
ru.yandex.qatools.matchers.collection.ContainsUniqueItems Maven / Gradle / Ivy
package ru.yandex.qatools.matchers.collection;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
/**
* @author Artem Koshelev artkoshelev
* @author Innokenty Shuvalov innokenty-shuvalov
* @param
*/
public class ContainsUniqueItems extends TypeSafeMatcher> {
public void describeTo(Description description) {
description.appendText("an iterable object where all elements are different");
}
@Override
protected boolean matchesSafely(Iterable extends T> iterable) {
return Sets.newHashSet(iterable).size() == Lists.newArrayList(iterable).size();
}
@Factory
public static Matcher> containsUniqueItems() {
return new ContainsUniqueItems();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy