List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:Main.java
@Nullable public static String[] nullableArrayOfStrings(@Nullable List<String> list) { return list == null || list.isEmpty() ? null : list.toArray(new String[list.size()]); }
From source file:Main.java
public static boolean isEmpty(List list) { if (list == null || list.isEmpty()) { return true; } else {//from w w w . j a va 2 s . c om return false; } }
From source file:Main.java
private static <T> T remove(List<T> list, int position) { if (list.isEmpty()) { return null; }/*from ww w. j ava 2 s. c o m*/ return list.remove(position); }
From source file:Main.java
public static Double listSum(List<Double> list) { if (list == null || list.isEmpty()) { return null; }/* w w w .ja v a 2s . co m*/ Double sum = 0.0; for (Double value : list) { sum += value; } return sum; }
From source file:Main.java
/** * // w w w . j a v a 2s. c o m * Internal method to check if a tuple sequence contains sequences or only * atomic values. * * @param <E> * the type of contained items * @param sequence * the sequence * @return <code>true</code> if sequence has to atomfiy, <code>false</code> * otherwise */ private static <E extends Object> boolean hasToAtomify(List<E> sequence) { if (sequence.isEmpty()) { return false; } for (E obj : sequence) { if (obj instanceof List<?>) { return true; } } return false; }
From source file:Main.java
public static <T> T zeroOrOne(List<? extends T> items) { return items == null || items.isEmpty() ? null : items.get(0); }
From source file:Main.java
private static <T> T remove(List<T> list, int position) { if (list.isEmpty()) return null; return list.remove(position); }
From source file:Main.java
public static String listToString(List<String> weeks) { if (weeks == null || weeks.isEmpty()) { return ""; }/* ww w . j a v a 2s.c o m*/ StringBuffer result = new StringBuffer(); for (String week : weeks) { result.append(week).append(","); } if (result.length() != 0) { result.deleteCharAt(result.length() - 1); } return result.toString(); }
From source file:Main.java
public static <T> List<T> nonNullFrom(List<T> list) { if (list == null || list.isEmpty()) { return Collections.emptyList(); }// w w w . j a v a 2 s . c om return Collections.unmodifiableList(list); }
From source file:Main.java
public static <T> T getFirst(List<T> list) { T t = null;// w w w.ja v a2 s . c om if (list != null && !list.isEmpty()) { t = list.get(0); } return t; }