se.softhouse.common.guavaextensions.Sets2 Maven / Gradle / Ivy
/*
* Copyright 2017 Jonatan Jönsson
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package se.softhouse.common.guavaextensions;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.util.Objects.requireNonNull;
import static se.softhouse.common.guavaextensions.Lists2.unmodifiableIterator;
public final class Sets2
{
private Sets2()
{
}
/**
* Returns an unmodifiable view of the difference of two sets. The
* returned set contains all elements that are contained by {@code set1} and
* not contained by {@code set2}.
* Note: {@code set2} may also contain elements not
* present in {@code set1}; these are simply ignored!
*/
public static Set difference(final Set set1, final Set> set2)
{
requireNonNull(set1, "set1");
requireNonNull(set2, "set2");
final Predicate © 2015 - 2025 Weber Informatics LLC | Privacy Policy