Home | History | Annotate | Download | only in collections
      1 /*
      2  * Copyright (c) 2007 Mockito contributors
      3  * This program is made available under the terms of the MIT License.
      4  */
      5 package org.mockito.internal.util.collections;
      6 
      7 import java.util.LinkedHashSet;
      8 import java.util.Set;
      9 
     10 import static java.util.Arrays.asList;
     11 
     12 public abstract class Sets {
     13     public static Set<Object> newMockSafeHashSet(Iterable<Object> mocks) {
     14         return HashCodeAndEqualsSafeSet.of(mocks);
     15     }
     16 
     17     public static Set<Object> newMockSafeHashSet(Object... mocks) {
     18         return HashCodeAndEqualsSafeSet.of(mocks);
     19     }
     20 
     21     public static <T> Set<T> newSet(T ... elements) {
     22         if (elements == null) {
     23             throw new IllegalArgumentException("Expected an array of elements (or empty array) but received a null.");
     24         }
     25         return new LinkedHashSet<T>(asList(elements));
     26     }
     27 }
     28