net.dongliu.commons.lang.collection.Lists Maven / Gradle / Ivy
package net.dongliu.commons.lang.collection;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* utils method for list
*
* @author Dong Liu
*/
public class Lists {
/**
* get a list backend by Array.
*
* {@code List list = Lists.of("test", "test2");}
*
*/
@SafeVarargs
public static List of(T... values) {
return Arrays.asList(values);
}
/**
* get immutable list
*/
@SafeVarargs
public static List immutable(T... values) {
return Collections.unmodifiableList(of(values));
}
/**
* get immutable list
*/
public static List immutable(List list) {
return Collections.unmodifiableList(list);
}
}