com.fitbur.mockito.internal.matchers.And Maven / Gradle / Ivy
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package com.fitbur.mockito.internal.matchers;
import com.fitbur.mockito.ArgumentMatcher;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings("unchecked")
public class And implements ArgumentMatcher, Serializable {
private final List matchers;
public And(List matchers) {
this.matchers = matchers;
}
public boolean matches(Object actual) {
for (ArgumentMatcher matcher : matchers) {
if (!matcher.matches(actual)) {
return false;
}
}
return true;
}
public String toString() {
StringBuilder out = new StringBuilder();
out.append("and(");
for (Iterator it = matchers.iterator(); it.hasNext();) {
out.append(it.next().toString());
if (it.hasNext()) {
out.append(", ");
}
}
out.append(")");
return out.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy