![JAR search and dependency download from the Maven repository](/logo.png)
com.objogate.wl.swing.probe.SingleComponentFinder 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.probe;
import java.awt.Component;
import org.hamcrest.Description;
import com.objogate.wl.swing.ComponentFinder;
import com.objogate.wl.swing.ComponentSelector;
/**
* A ComponentFinder that is satisfied only if it finds a single, matching component.
*/
public class SingleComponentFinder implements ComponentSelector {
private final ComponentFinder finder;
public SingleComponentFinder(ComponentFinder finder) {
this.finder = finder;
}
public T component() {
return components().get(0);
}
public java.util.List components() {
return finder.components();
}
public boolean isSatisfied() {
return finder.isSatisfied() && isSingle();
}
public void probe() {
finder.probe();
}
public void describeTo(Description description) {
description.appendText("exactly 1 ")
.appendDescriptionOf(finder);
}
/**
* This expects the ComponentFinder it wraps to describe how many were actually found.
*/
public void describeFailureTo(Description description) {
finder.describeFailureTo(description);
}
private boolean isSingle() {
return components().size() == 1;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy