test.ca.odell.glazedlists.CollectionMatcherEditor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
/* Glazed Lists (c) 2003-2006 */
/* http://publicobject.com/glazedlists/ publicobject.com,*/
/* O'Dell Engineering Ltd.*/
package ca.odell.glazedlists;
import ca.odell.glazedlists.matchers.Matcher;
import ca.odell.glazedlists.matchers.AbstractMatcherEditor;
import java.util.Collection;
import java.util.Collections;
/**
* A simple matcher editor that uses set collection for matching.
*
* @author Jesse Wilson
*/
public class CollectionMatcherEditor extends AbstractMatcherEditor {
private Collection current = null;
public void matchAll() {
current = null;
fireMatchAll();
}
public void matchNone() {
current = Collections.EMPTY_LIST;
fireMatchNone();
}
public void setCollection(Collection values) {
boolean relaxed = current != null && values.containsAll(current);
boolean constrained = current == null || current.containsAll(values);
this.current = values;
CollectionMatcher matcherEditor = new CollectionMatcher(values);
if(relaxed) {
fireRelaxed(matcherEditor);
} else if(constrained) {
fireConstrained(matcherEditor);
} else {
fireChanged(matcherEditor);
}
}
private static class CollectionMatcher implements Matcher {
private final Collection values;
public CollectionMatcher(Collection values) {
this.values = values;
}
public boolean matches(E item) {
return values.contains(item);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy