List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:com.mobius.software.mqtt.performance.runner.util.FileUtil.java
public static void logErrors(UUID scenarioID, List<ClientReport> reports) { if (reports.isEmpty()) return;/*from w ww .j a v a 2 s . co m*/ String filename = DIRECTORY_NAME + File.separator + scenarioID.toString() + LOG_EXTENSION; File log = new File(filename); if (!log.getParentFile().exists()) log.getParentFile().mkdir(); try (PrintWriter pw = new PrintWriter(log)) { for (ClientReport clientReport : reports) { List<ErrorReport> errorReports = clientReport.getErrors(); if (!errorReports.isEmpty()) { String errorContent = ReportBuilder.buildError(clientReport.getIdentifier(), errorReports); pw.println(errorContent); } } } catch (IOException e) { logger.error("An error occured while writing error reports to file:" + e.getMessage()); } if (log.length() == 0) log.delete(); }
From source file:Main.java
/** * This method checks if the list is not null and have elements. * /*from w ww . ja v a2 s. co m*/ * @param <E> * * @param list * the list to check * @return true/false */ public static <E> boolean isNotEmpty(List<E> list) { return list != null && !list.isEmpty(); }
From source file:Main.java
public static boolean isLauncherActivity(Context context, String packageName) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mainIntent.setPackage(packageName);// w w w . j a v a2 s .com List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(mainIntent, 0); if (infoList.isEmpty()) { return false; } else { return true; } }
From source file:Main.java
protected static Type getGenericParameter(Type type, int index) { if (!ParameterizedType.class.isInstance(type)) { return null; }/*w ww. jav a 2 s. c o m*/ final List<Type> genericParameter = getGenericParameterList(type); if (genericParameter.isEmpty()) { return null; } return genericParameter.get(index); }
From source file:org.confab.Utilities.java
public static void printCookieStore(CookieStore cookieStore) { debug("printCookies"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else {/*from www .jav a 2 s. c o m*/ for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } debug("end printCookies"); }
From source file:com.aimluck.eip.modules.actions.project.util.ProjectTestUtil.java
public static <T> List<List<T>> devide(List<T> origin, int size) { if (origin == null || origin.isEmpty() || size <= 0) { return Collections.emptyList(); }/* ww w . j a v a 2s .c om*/ int block = origin.size() / size + (origin.size() % size > 0 ? 1 : 0); List<List<T>> devidedList = new ArrayList<List<T>>(block); for (int i = 0; i < block; i++) { int start = i * size; int end = Math.min(start + size, origin.size()); devidedList.add(new ArrayList<T>(origin.subList(start, end))); } return devidedList; }
From source file:Main.java
public static boolean isIntentResolvable(Context context, Intent intent) { final PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, 0); return resolveInfo != null && !resolveInfo.isEmpty(); }
From source file:Main.java
/** * Utility method to check if a shortcut can be added to the homescreen. * @param context Context used to get the package manager. * @return if a shortcut can be added to the homescreen under the current profile. *///from ww w.ja va 2 s . c o m public static boolean isAddToHomeIntentSupported(Context context) { PackageManager pm = context.getPackageManager(); Intent i = new Intent(INSTALL_SHORTCUT); List<ResolveInfo> receivers = pm.queryBroadcastReceivers(i, PackageManager.GET_INTENT_FILTERS); return !receivers.isEmpty(); }
From source file:Main.java
/** * //w w w . java 2 s .com * @param <T> * @param list * @param comparator * @return * @author sabuj.das */ public static <T> T lowestValue(List<T> list, Comparator<T> comparator) { if (list == null || list.isEmpty()) { return null; } Collections.sort(list, comparator); return list.get(0); }
From source file:Main.java
public static <T> List<T> sub(List<T> list, int start, int end) { if (list == null || list.isEmpty()) { return null; }//from w w w. ja v a 2s .com if (start < 0) { start = 0; } if (end < 0) { end = 0; } if (start > end) { int tmp = start; start = end; end = tmp; } final int size = list.size(); if (end > size) { if (start >= size) { return null; } end = size; } return list.subList(start, end); }