Example usage for java.util ArrayList isEmpty

List of usage examples for java.util ArrayList isEmpty

Introduction

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

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:Main.java

public static <T> ArrayList<T> remove(ArrayList<T> cur, T val) {
    if (cur == null) {
        return null;
    }/*from   w  w  w .j  a v  a 2s  .  c o m*/
    cur.remove(val);
    if (cur.isEmpty()) {
        return null;
    } else {
        return cur;
    }
}

From source file:com.flexive.shared.mbeans.MBeanHelper.java

private static List<MBeanServer> findMBeanServers() {
    final ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
    if (servers.isEmpty()) {
        LOG.error("No active JMX MBean servers found - creating a new one");
        servers.add(MBeanServerFactory.createMBeanServer());
    }/*from w  w w .  j  av a  2 s . c om*/
    return servers;
}

From source file:Main.java

public static boolean compareList(List<?> l1, List<?> l2) {
    // make a copy of the list so the original list is not changed, and remove() is supported
    ArrayList<?> cp = new ArrayList<>(l1);
    for (Object o : l2) {
        if (!cp.remove(o)) {
            return false;
        }//from  w  ww  .  j a v  a 2s  .  c  o  m
    }
    return cp.isEmpty();
}

From source file:it.serasoft.pdi.PDITools.java

private static void startReadingDir(String srcDir, boolean recurse, boolean followLinks) {

    File f = new File(srcDir);

    if (!f.isDirectory())
        // TODO Manage directory is not a directory
        System.exit(-3);/*  ww w. j ava 2s  .c  om*/

    ArrayList<File> completeFilesList = new ArrayList<>();
    getFilesList(f, completeFilesList, recurse);

    if (!completeFilesList.isEmpty()) {
        completeFilesList.forEach(file -> startAnalysis(file, followLinks));
    }
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.IOHelper.java

/**
 * Lists all xml files and throw an IOException if no XML files were found
 *
 * @param inputDir input dir//from  w w  w. j a v a  2 s.c o  m
 * @return list of xml files
 * @throws IOException exception
 */
public static List<File> listXmlFiles(File inputDir) throws IOException {
    ArrayList<File> files = new ArrayList<>(FileUtils.listFiles(inputDir, new String[] { "xml" }, false));

    if (files.isEmpty()) {
        throw new IOException("No xml files found in " + inputDir);
    }

    return files;
}

From source file:FileUtils.java

public static String relativePath(String fromPath, String toPath, boolean fromIsDirectory, char separatorChar) {
    ArrayList<String> fromElements = splitPath(fromPath);
    ArrayList<String> toElements = splitPath(toPath);
    while (!fromElements.isEmpty() && !toElements.isEmpty()) {
        if (!(fromElements.get(0).equals(toElements.get(0)))) {
            break;
        }/*w ww.j av a  2  s.co  m*/
        fromElements.remove(0);
        toElements.remove(0);
    }

    StringBuffer result = new StringBuffer();
    for (int i = 0; i < fromElements.size() - (fromIsDirectory ? 0 : 1); i++) {
        result.append("..");
        result.append(separatorChar);
    }
    for (String s : toElements) {
        result.append(s);
        result.append(separatorChar);
    }
    return result.substring(0, result.length() - 1);
}

From source file:com.appassit.http.ApiRequestFactory.java

/**
 * POSTHttpEntity//from  w w  w.  j  a  v  a  2s  .  c  om
 * 
 * @param params
 *            ?
 * @throws UnsupportedEncodingException
 *             ???UTF8??
 */
private static HttpEntity getPostRequestEntity(ArrayList<BasicNameValuePair> params)
        throws UnsupportedEncodingException {
    if (params == null || params.isEmpty())
        return null;

    return new UrlEncodedFormEntity(params, HTTP.UTF_8);
}

From source file:cool.pandora.modeller.ui.handlers.iiif.PatchListHandler.java

private static RDFNode getResourceTarget(final String resourceURI) {
    final ResourceObjectNode resourceObjectNode = ResourceObjectNode.init().resourceURI(resourceURI)
            .resourceProperty(IIIFPredicates.ON).build();
    final ArrayList<RDFNode> resourceTarget = resourceObjectNode.render();
    if (resourceTarget.isEmpty()) {
        return null;
    }//  www . j  a  v  a2s  .c o  m
    return resourceTarget.get(0);
}

From source file:com.ettoremastrogiacomo.sktradingjava.starters.Temp.java

public static <T> java.util.Set<T> longestSet(ArrayList<TreeSet<T>> list) {
    if (list.isEmpty())
        return new java.util.TreeSet<>();
    java.util.TreeSet<T> best = list.get(0);
    for (TreeSet<T> s : list) {
        if (best.size() < s.size())
            best = s;/* w w  w  .  j  a  v  a 2s. c o  m*/
    }
    return best;
}

From source file:com.readystatesoftware.simpl3r.utils.SharedPreferencesUtils.java

public static void setStringArrayPref(SharedPreferences prefs, String key, ArrayList<String> values) {
    SharedPreferences.Editor editor = prefs.edit();
    JSONArray a = new JSONArray();
    for (int i = 0; i < values.size(); i++) {
        a.put(values.get(i));/*from w  w  w.  j ava2s  .  c  o  m*/
    }
    if (!values.isEmpty()) {
        editor.putString(key, a.toString());
    } else {
        editor.putString(key, null);
    }
    SharedPreferencesCompat.apply(editor);
}