All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.yandex.qatools.matchers.collection.ContainsUniqueItems Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
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 iterable) {
		return Sets.newHashSet(iterable).size() == Lists.newArrayList(iterable).size();
	}

	@Factory
	public static  Matcher> containsUniqueItems() {
		return new ContainsUniqueItems();
	}
}