01: package abbot.finder.matchers;
02:
03: import java.awt.Component;
04:
05: /** Provides matching of components by class. */
06: public class ClassMatcher extends AbstractMatcher {
07: private Class cls;
08: private boolean mustBeShowing;
09:
10: public ClassMatcher(Class cls) {
11: this (cls, false);
12: }
13:
14: public ClassMatcher(Class cls, boolean mustBeShowing) {
15: this .cls = cls;
16: this .mustBeShowing = mustBeShowing;
17: }
18:
19: public boolean matches(Component c) {
20: return cls.isAssignableFrom(c.getClass())
21: && (!mustBeShowing || c.isShowing());
22: }
23:
24: public String toString() {
25: return "Class matcher (" + cls.getName() + ")";
26: }
27: }
|