blob: 9310abfc0c91427f6a6c0026f21cc73d4a98bc2a [file] [log] [blame]
package org.hamcrest.internal;
import org.hamcrest.Matcher;
import org.hamcrest.core.IsNull;
import java.util.ArrayList;
import java.util.List;
public class NullSafety {
@SuppressWarnings("unchecked")
public static <E> List<Matcher<? super E>> nullSafe(Matcher<? super E>[] itemMatchers) {
final List<Matcher<? super E>> matchers = new ArrayList<Matcher<? super E>>(itemMatchers.length);
for (final Matcher<? super E> itemMatcher : itemMatchers) {
matchers.add((Matcher<? super E>) (itemMatcher == null ? IsNull.nullValue() : itemMatcher));
}
return matchers;
}
}