com.objogate.wl.swing.matcher.CollectionSizeMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of windowlicker-swing Show documentation
Show all versions of windowlicker-swing Show documentation
This is the Windowlicker Swing library.
The newest version!
package com.objogate.wl.swing.matcher;
import java.util.Collection;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import static org.hamcrest.Matchers.equalTo;
import org.hamcrest.TypeSafeMatcher;
public class CollectionSizeMatcher> extends TypeSafeMatcher {
private final Matcher sizeMatcher;
public CollectionSizeMatcher(Matcher sizeMatcher) {
this.sizeMatcher = sizeMatcher;
}
@Override
public boolean matchesSafely(C collection) {
return sizeMatcher.matches(collection.size());
}
public void describeTo(Description description) {
description.appendText("a collection with size ").appendDescriptionOf(sizeMatcher);
}
@Factory
public static > Matcher ofSize(Matcher sizeMatcher) {
return new CollectionSizeMatcher(sizeMatcher);
}
@Factory
public static > Matcher ofSize(int expectedSize) {
return ofSize(equalTo(expectedSize));
}
}