com.cedarsoft.test.utils.matchers.AndMatcher Maven / Gradle / Ivy
package com.cedarsoft.test.utils.matchers;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Johannes Schneider ([email protected])
*/
class AndMatcher extends BaseMatcher {
private final List> matchers;
public AndMatcher(List extends Matcher>> matchers) {
this.matchers = new ArrayList>(matchers);
}
@Override
public boolean matches(Object argument) {
for (Matcher> matcher : matchers) {
if (!matcher.matches(argument)) {
return false;
}
}
return true;
}
@Override
public void describeTo( Description description ) {
description.appendText( "and(" );
for ( Iterator> it = matchers.iterator(); it.hasNext(); ) {
it.next().describeTo( description );
if ( it.hasNext() ) {
description.appendText( ", " );
}
}
description.appendText( ")" );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy