com.github.paganini2008.devtools.collection.SetUtils Maven / Gradle / Ivy
package com.github.paganini2008.devtools.collection;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* SetUtils
*
* @author Fred Feng
* @version 1.0
*/
@SuppressWarnings("all")
public abstract class SetUtils {
public static Set unmodifiableSet(T... args) {
return Collections.unmodifiableSet(create(args));
}
public static Set unmodifiableSet(Collection c) {
return Collections.unmodifiableSet((c instanceof Set ? (Set) c : new HashSet(c)));
}
public static Set create(T... args) {
return toSet(Arrays.asList(args));
}
public static Set toSet(Collection c) {
return c instanceof Set ? (Set) c : new HashSet(c);
}
public static boolean isSet(Object obj) {
return obj == null ? false : obj instanceof Set;
}
public static boolean isNotSet(Object obj) {
return !isSet(obj);
}
}