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

com.fitbur.mockito.internal.util.collections.Sets 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.util.collections;


import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import static java.util.Arrays.asList;

public abstract class Sets {
    public static Set newMockSafeHashSet(Iterable mocks) {
        return HashCodeAndEqualsSafeSet.of(mocks);
    }

    public static Set newMockSafeHashSet(Object... mocks) {
        return HashCodeAndEqualsSafeSet.of(mocks);
    }

    public static IdentitySet newIdentitySet() {
        return new IdentitySet();
    }

    public static  Set newSet(T ... elements) {
        if (elements == null) {
            throw new IllegalArgumentException("Expected an array of elements (or empty array) but received a null.");
        }
        return new LinkedHashSet(asList(elements));
    }
}