Example usage for java.util List isEmpty

List of usage examples for java.util List isEmpty

Introduction

In this page you can find the example usage for java.util List isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:Main.java

static public boolean isAppInForeground(Context context) {
    List<ActivityManager.RunningTaskInfo> tasks = ((ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(1);
    if (tasks.isEmpty()) {
        return false;
    }/*w w w . j  av  a  2s . c  o  m*/
    return tasks.get(0).topActivity.getPackageName().equalsIgnoreCase(context.getPackageName());
}

From source file:com.dattack.dbtools.drules.DrulesClient.java

private static void showTaskList(final List<Identifier> taskList) {

    if (taskList == null || taskList.isEmpty()) {
        System.out.println("There are no tasks available to you yet");
    } else {/*from w  w w .  ja  va  2s.c  o  m*/
        System.out.println("Available tasks:");
        for (int index = 0; index < taskList.size(); index++) {
            System.out.format("  % 3d) %s%n", index + 1, taskList.get(index).getValue());
        }
    }
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.util.MetaSanitizerUtil.java

/**
 * Takes a List of KeywordModels and returns a comma separated list of keywords as String.
 *
 * @param keywords//from   w  ww.j a v  a 2s. co  m
 *           List of KeywordModel objects
 * @deprecated use {@link MetaSanitizerUtil#sanitizeKeywords(Collection)} instead
 * @return String of comma separated keywords
 */
@Deprecated
public static String sanitizeKeywords(final List<KeywordModel> keywords) {
    if (keywords != null && !keywords.isEmpty()) {
        // Remove duplicates
        final Set<String> keywordSet = new HashSet<String>(keywords.size());
        for (final KeywordModel keyword : keywords) {
            keywordSet.add(keyword.getKeyword());
        }

        return sanitizeKeywords(keywordSet);
    }
    return "";
}

From source file:Main.java

public static boolean isServiceRunning(Context context, String className) {
    boolean isRunning = false;
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> serviceList = activityManager
            .getRunningServices(Integer.MAX_VALUE);
    if (serviceList == null || serviceList.isEmpty())
        return false;
    for (int i = 0; i < serviceList.size(); i++) {
        if (serviceList.get(i).service.getClassName().equals(className)
                && TextUtils.equals(serviceList.get(i).service.getPackageName(), context.getPackageName())) {
            isRunning = true;/*from w  ww.j  a  v  a  2  s.  c om*/
            break;
        }
    }
    return isRunning;
}

From source file:com.diversityarrays.util.ClassPathExtender.java

public static void addDirectoryJarsToClassPath(Consumer<File> jarChecker, List<File> dirs, Log logger) {
    if (!dirs.isEmpty()) {
        addDirectoryJarsToClassPath(logger, jarChecker, dirs.toArray(new File[dirs.size()]));
    }/*from   w  w w  .  j ava2  s.  co m*/
}

From source file:com.cognifide.qa.bb.aem.core.sidepanel.internal.ComponentTreeLocatorHelper.java

private static WebElement setComponent(WebElement component, String container) {
    List<WebElement> elements = component.findElements(By.className("coral3-Tree-item--drilldown"));
    if (!elements.isEmpty()) {
        return elements.get(calculateElementNumber(container));
    }/*from w ww  .  j  a va 2s.c om*/
    return component;
}

From source file:Main.java

/**
 * Parses a var which might be comma delimited, e.g. bla,foo:1000: if 'bla' is set, return its value. Else,
 * if 'foo' is set, return its value, else return "1000"
 * @param var/*  w w  w  .j a v a  2 s .  c  om*/
 * @param default_value
 * @return
 */
private static String _getProperty(String var, String default_value) {
    if (var == null)
        return null;
    List<String> list = parseCommaDelimitedStrings(var);
    if (list == null || list.isEmpty()) {
        list = new ArrayList<String>(1);
        list.add(var);
    }
    String retval = null;
    for (String prop : list) {
        try {
            retval = System.getProperty(prop);
            if (retval != null)
                return retval;
        } catch (Throwable e) {
        }
    }
    return default_value;
}

From source file:de.oth.keycloak.InitKeycloakServer.java

private static void addUsers(RealmResource rRes, List<UserConfig> userList) {
    if (userList == null || userList.isEmpty()) {
        return;//from w  w w.j  a va  2  s . co m
    }
    for (UserConfig userConfig : userList) {
        String login = userConfig.getLogin();
        String firstName = userConfig.getFirstName();
        String lastName = userConfig.getLastName();
        UserResource userRes = KeycloakAccess.getUserFromRealm(rRes, firstName, lastName, login);
        boolean bAdd = false;
        if (userRes == null) {
            userRes = KeycloakAccess.addUserToRealm(rRes, firstName, lastName, login);
            bAdd = true;
        }
        String groupName = userConfig.getUserGroup();
        KeycloakAccess.setGroupForUser(rRes, userRes, userConfig.getUserGroup());
        if (bAdd) {
            KeycloakAccess.setPasswordForUser(rRes, userRes, userConfig.getPassword());
        }
    }
}

From source file:edu.usu.sdl.openstorefront.service.manager.ReportManager.java

public static void init() {
    ServiceProxy serviceProxy = ServiceProxy.getProxy();
    //Restart any pending or working reports
    List<Report> allReports = getInprogessReports();

    if (!allReports.isEmpty()) {
        log.log(Level.INFO, MessageFormat.format(
                "Resuming pending and working reports. (Running in the Background)  Reports to run:  {0}",
                allReports.size()));//from ww  w .j  av a 2  s .com
        for (Report report : allReports) {
            TaskRequest taskRequest = new TaskRequest();
            taskRequest.setAllowMultiple(true);
            taskRequest.setName(TaskRequest.TASKNAME_REPORT);
            taskRequest.setDetails("Report: " + report.getReportType() + " Report id: " + report.getReportId()
                    + " for user: " + SecurityUtil.getCurrentUserName());
            taskRequest.getTaskData().put(TaskRequest.DATAKEY_REPORT_ID, report.getReportId());
            serviceProxy.getAsyncProxy(serviceProxy.getReportService(), taskRequest).generateReport(report);
        }
    }

}

From source file:Main.java

/**
 * This method returns a new ArrayList which is the intersection of the two List parameters, based on {@link Object#equals(Object) equality}
 * of their elements./*w ww  . ja v a 2  s . co  m*/
 * The intersection list will contain elements in the order they have in list1 and any references in the resultant list will be
 * to elements within list1 also.
 * 
 * @return a new ArrayList whose values represent the intersection of the two Lists.
 */
public static <T> List<T> intersect(List<? extends T> list1, List<? extends T> list2) {
    if (list1 == null || list1.isEmpty() || list2 == null || list2.isEmpty()) {
        return Collections.emptyList();
    }

    List<T> result = new ArrayList<T>();
    result.addAll(list1);

    result.retainAll(list2);

    return result;
}