List of usage examples for java.util Collections emptyList
@SuppressWarnings("unchecked") public static final <T> List<T> emptyList()
From source file:Main.java
public static <K, V> List<V> getValueList(Map<K, List<V>> map, K key) { List<V> valueList = map.get(key); if (valueList == null) return Collections.emptyList(); return valueList; }
From source file:Main.java
public static <T> List<T> asList(T... args) { if (args == null || args.length == 0) { return Collections.emptyList(); }/* w ww .j a va 2 s . c o m*/ return Arrays.asList(args); }
From source file:Main.java
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> collection) { if (collection == null) { return Collections.emptyList(); } else {//from w w w . j av a 2s .com return Collections.unmodifiableCollection(collection); } }
From source file:Main.java
public static <T> List<T> safe(List<T> l) { if (l == null) { return Collections.emptyList(); }/*from w ww . j av a 2 s . c o m*/ return l; }
From source file:Main.java
public static List<Thread> getGroupThreads(ThreadGroup threadGroup) { if (threadGroup == null) { return Collections.emptyList(); }// ww w . j a v a 2 s. c om Thread[] threadArray = new Thread[threadGroup.activeCount() * 2]; threadGroup.enumerate(threadArray); return Arrays.asList(threadArray); }
From source file:Main.java
/** * If list is null, change to empty list *//*from w ww . j ava 2 s . c o m*/ public static <T> List<T> notNull(List<T> list) { if (list == null) { return Collections.emptyList(); } return list; }
From source file:Main.java
public static <V> List<V> subList(List<V> list, int startIndex, int count) { if (null == list || startIndex >= list.size() || count <= 0) { return Collections.emptyList(); }//from w ww .j a v a2 s. com int endIndex = Math.min(startIndex + count, list.size()); return list.subList(startIndex, endIndex); }
From source file:Main.java
public static <T> List<T> nonNullList(final List<T> list) { if (list == null) { return Collections.emptyList(); }/*from www. j av a 2s .c o m*/ return list; }
From source file:Main.java
public static <T> List<T> readOnlyCopy(List<T> orig) { if (orig.isEmpty()) return Collections.emptyList(); if (orig.size() == 1) return Collections.singletonList(orig.get(0)); ArrayList<T> copy = new ArrayList<>(orig.size()); copy.addAll(orig);//from ww w. j av a2s . c o m return Collections.unmodifiableList(copy); }
From source file:Main.java
public static <T> List<T> circleSubList(List<T> srcList, int position, int count) { if (srcList == null || srcList.size() == 0) { return Collections.emptyList(); }/* w w w. j a v a 2s .c o m*/ position = position < 0 ? 0 : position; count = count > srcList.size() ? srcList.size() : count; if (position > srcList.size() - 1) { return srcList.subList(0, count); } if (position + count <= srcList.size()) { return srcList.subList(position, (position + count)); } List<T> fList = srcList.subList(position, srcList.size()); List<T> eList = srcList.subList(0, count - srcList.size() + position); fList.addAll(eList); return fList; }