List of usage examples for java.util Collections unmodifiableList
public static <T> List<T> unmodifiableList(List<? extends T> list)
From source file:Main.java
public static <T> List<T> immutableList(Collection<? extends T> list) { if (list == null) return Collections.emptyList(); return Collections .unmodifiableList(list instanceof List ? (List<? extends T>) list : new ArrayList<T>(list)); }
From source file:Main.java
public static <T> List<T> unmodifiableList(T... array) { return Collections.unmodifiableList(Arrays.asList(array)); }
From source file:Main.java
public static <T> List<T> unmodifiableArrayList(Collection<T> elements) { return Collections.unmodifiableList(new ArrayList<T>(elements)); }
From source file:Main.java
/** * Array to unmodifiable list.//from w w w . j a va2 s . c o m * @param values an array. * @param <T> type of array element. * @return unmodifiable list. */ public static <T> List<T> unmodifiableList(T[] values) { return Collections.unmodifiableList(Arrays.asList(values)); }
From source file:Main.java
public static <A> List<A> append(A a, List<A> as) { List<A> result = new ArrayList<A>(as); result.add(a);/*from w ww . j a va 2 s . c om*/ return Collections.unmodifiableList(result); }
From source file:Main.java
public static <T> List<T> asUnmodifiableList(@SuppressWarnings("unchecked") T... ts) { List<T> l = new ArrayList<>(); for (T t : ts) { l.add(t);/*from w w w .j av a 2 s. c om*/ } return Collections.unmodifiableList(l); }
From source file:Main.java
public static <E> List<E> toList(Iterable<? extends E> iterable) { final List<E> list = new ArrayList<E>(); for (E e : iterable) { list.add(e);//from w w w .j a va 2 s . c om } return Collections.unmodifiableList(list); }
From source file:Main.java
public static <E> List<E> copyNullSafeList(Collection<? extends E> list) { if (list.isEmpty()) { return Collections.emptyList(); }//from w w w . ja va2 s . c o m return Collections.unmodifiableList(copyNullSafeMutableList(list)); }
From source file:Main.java
public static ObservableList<String> unmodifiableList(String... array) { return FXCollections.observableArrayList(Collections.unmodifiableList(Arrays.asList(array))); }
From source file:Main.java
public static <T> List<T> tail(List<T> list) { if (list.size() == 0) { throw new IllegalStateException("tail of empty list"); }/*from w ww.j a v a 2s . c o m*/ List<T> workList = copy(list); workList.remove(0); return Collections.unmodifiableList(workList); }