com.github.liuyehcf.framework.compile.engine.utils.SetUtils Maven / Gradle / Ivy
package com.github.liuyehcf.framework.compile.engine.utils;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* Set工具类
*
* @author hechenfeng
* @date 2018/04/16
*/
public abstract class SetUtils {
@SafeVarargs
public static Set of(T... elements) {
return new HashSet<>((Arrays.asList(elements)));
}
public static Set extract(Set set, T element) {
Set newSet = new HashSet<>(set);
newSet.remove(element);
return newSet;
}
public static Set of(Set set1, Set set2) {
Set newSet = new HashSet<>(set1);
newSet.addAll(set2);
return newSet;
}
}