1 package org.hamcrest.internal; 2 3 import org.hamcrest.Matcher; 4 import org.hamcrest.core.IsNull; 5 6 import java.util.ArrayList; 7 import java.util.List; 8 9 public class NullSafety { 10 @SuppressWarnings("unchecked") 11 public static <E> List<Matcher<? super E>> nullSafe(Matcher<? super E>[] itemMatchers) { 12 final List<Matcher<? super E>> matchers = new ArrayList<Matcher<? super E>>(itemMatchers.length); 13 for (final Matcher<? super E> itemMatcher : itemMatchers) { 14 matchers.add((Matcher<? super E>) (itemMatcher == null ? IsNull.nullValue() : itemMatcher)); 15 } 16 return matchers; 17 } 18 } 19