com.objogate.wl.swing.matcher.TableRowCountMatcher 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 javax.swing.JTable;
import java.awt.Component;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import static org.hamcrest.Matchers.equalTo;
import org.hamcrest.TypeSafeMatcher;
public class TableRowCountMatcher extends TypeSafeMatcher {
private final Matcher rowCountMatcher;
public TableRowCountMatcher(Matcher rowCountMatcher) {
this.rowCountMatcher = rowCountMatcher;
}
@Override
public boolean matchesSafely(Component component) {
return component instanceof JTable
&& matchesSafely((JTable) component);
}
public boolean matchesSafely(JTable table) {
return rowCountMatcher.matches(table.getRowCount());
}
public void describeTo(Description description) {
description.appendText("with row count ");
rowCountMatcher.describeTo(description);
}
public static Matcher withRowCount(int n) {
return withRowCount(equalTo(n));
}
public static Matcher withRowCount(Matcher rowCountMatcher) {
return new TableRowCountMatcher(rowCountMatcher);
}
}