All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.mockito.internal.matchers.Or Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * 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 Or implements ArgumentMatcher, Serializable {

    private final List matchers;

    public Or(List matchers) {
        this.matchers = matchers;
    }

    public boolean matches(Object actual) {
        for (ArgumentMatcher matcher : matchers) {
            if (matcher.matches(actual)) {
                return true;
            }
        }
        return false;
    }

    public String toString() {
        //TODO SF here and in other places we should reuse ValuePrinter
        StringBuilder sb = new StringBuilder("or(");
        for (Iterator it = matchers.iterator(); it.hasNext();) {
            sb.append(it.next().toString());
            if (it.hasNext()) {
                sb.append(", ");
            }
        }
        return sb.append(")").toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy