List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:Main.java
public static boolean isNotNullAndNotEmpty(ArrayList list) { return list != null || !list.isEmpty(); }
From source file:Main.java
public static <T> T last(Collection<? extends T> collection) { ArrayList<T> list = new ArrayList<>(collection); return list.isEmpty() ? null : list.get(list.size() - 1); }
From source file:Main.java
public static <T> T first(Collection<? extends T> collection) { ArrayList<T> list = new ArrayList<>(collection); return list.isEmpty() ? null : list.get(0); }
From source file:Main.java
private static String listToString(ArrayList<String> pathSpec) { if (pathSpec.isEmpty()) return ""; StringBuilder ret = new StringBuilder(); ret.append(pathSpec.get(0));// w w w. ja va2s . co m for (int i = 1, n = pathSpec.size(); i < n; i++) ret.append(File.separator).append(pathSpec.get(i)); return ret.toString(); }
From source file:Main.java
public static int indexOfItem(ArrayList<String> list, final String item) { if (item == null || list.isEmpty()) { return -1; }//from www. j a v a 2 s .com for (int i = 0; i < list.size(); i++) { if (item.equals(list.get(i))) { return i; } } return -1; }
From source file:Main.java
public static boolean isEmpty(ArrayList<?> arrayList) { return arrayList == null || arrayList.isEmpty(); }
From source file:Main.java
public static Element getFirstElementByTagName(Node node, String tagName) { ArrayList<Element> elements = getElementsByTagName(node, tagName); if (!elements.isEmpty()) return elements.get(0); return null;//from w ww. j a va2s .c o m }
From source file:Main.java
public static MBeanServer findMBeanServer() { ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); if (servers == null || servers.isEmpty()) { return ManagementFactory.getPlatformMBeanServer(); }/*from w ww .j a va 2s . co m*/ return servers.get(0); }
From source file:Main.java
public static String arrayParamToString(ArrayList<String> strings) { String arrayToStringParam = ""; if (strings != null && !strings.isEmpty()) { for (int i = 0; i < strings.size(); i++) { String param = strings.get(i); if (i == 0) arrayToStringParam += param; else/*from w ww . j av a2 s.c o m*/ arrayToStringParam += "," + param; } } return arrayToStringParam; }
From source file:Main.java
public static String getTabsStringFromList(final ArrayList<String> tabs) { final StringBuilder resultTabs; if (tabs == null || tabs.isEmpty()) { resultTabs = new StringBuilder(""); } else {// www. j a v a 2s. co m resultTabs = new StringBuilder(tabs.size() * 10); resultTabs.append(tabs.get(0)); for (int i = 1; i < tabs.size(); i++) { resultTabs.append(LIBRARY_TABS_DELIMITER); resultTabs.append(tabs.get(i)); } } return resultTabs.toString(); }