Example usage for java.util Collection isEmpty

List of usage examples for java.util Collection isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this collection contains no elements.

Usage

From source file:org.cloudfoundry.maven.common.CommonUtils.java

/**
 * Formats the supported frameworks as a command separated list.
 *
 * @param offerings List of services/*from www  .  j a  v  a 2 s .  c o m*/
 * @return a String but never null
 */
public static String serviceOfferingsToCommaDelimitedString(final Collection<CloudServiceOffering> offerings) {

    if (offerings == null || offerings.isEmpty()) {
        return "";
    }

    StringBuilder sb = new StringBuilder();
    final Iterator<CloudServiceOffering> it = offerings.iterator();

    while (it.hasNext()) {
        CloudServiceOffering offering = it.next();
        sb.append(offering.getLabel());

        if (it.hasNext()) {
            sb.append(", ");
        }
    }
    return sb.toString();
}

From source file:com.jlfex.hermes.common.utils.CollectionUtil.java

/**
 * ?.//from   w ww . jav a  2 s  .c  o m
 */
@SuppressWarnings("rawtypes")
public static boolean isEmpty(Collection collection) {
    return (collection == null) || collection.isEmpty();
}

From source file:net.landora.video.utils.UIUtils.java

public static <T> T select(Collection<T> collection) {
    if (collection == null || collection.isEmpty()) {
        return null;
    } else {//from   w w w. java2s  . co  m
        return collection.iterator().next();
    }
}

From source file:com.github.rwitzel.streamflyer.internal.thirdparty.ZzzValidate.java

/**
 * Validates that the given collection is not empty.
 * /*from  www .j ava2 s  .c  o m*/
 * @param collection
 * @param collectionName
 */
public static void isNotEmpty(Collection<?> collection, String collectionName) {
    notNull(collection, collectionName + " must not be null");
    isTrue(!collection.isEmpty(), collectionName + " must not be empty");
}

From source file:com.jlfex.hermes.common.utils.CollectionUtil.java

/**
 * ?./*from  ww  w.  ja  va2s .  c  o  m*/
 */
@SuppressWarnings("rawtypes")
public static boolean isNotEmpty(Collection collection) {
    return (collection != null) && !(collection.isEmpty());
}

From source file:coolmap.application.plugin.PluginMaster.java

public static void initialize() {
    String pluginPath;//from  w  w w .ja v a 2s . c  o m
    if (Config.isInitialized()) {
        pluginPath = Config.getProperty(Config.PLUGIN_DIRECTORY);
    } else {
        pluginPath = "plugin";
    }

    File pluginFolder = new File(pluginPath);

    //        System.out.println(pluginFolder.getAbsolutePath());
    pluginManager = PluginManagerFactory.createPluginManager();
    pluginManager.addPluginsFrom(pluginFolder.toURI());

    //        after loading everything
    pluginManagerUtil = new PluginManagerUtil(pluginManager);
    Collection<CoolMapPlugin> plugins = pluginManagerUtil.getPlugins(CoolMapPlugin.class);

    Collection<PluginInformation> pluginInfo = pluginManagerUtil.getPlugins(PluginInformation.class);

    PluginInformationImpl piImpl = null;
    if (!pluginInfo.isEmpty()) {
        piImpl = (PluginInformationImpl) pluginInfo.iterator().next();
    }

    for (CoolMapPlugin plugin : plugins) {
        try {

            CMConsole.logInfo("Loaded " + plugin.getName() + " plugin");
            //                System.out.println(plugin.getName());
            JSONObject config = new JSONObject();
            if (piImpl != null) {
                //gets the string
                try {
                    Collection<String> paths = piImpl
                            .getInformation(PluginInformation.Information.CLASSPATH_ORIGIN, plugin);
                    if (!paths.isEmpty()) {
                        config.put(CoolMapPluginTerms.ATTR_URI, paths.iterator().next());
                    }
                } catch (Exception e) {
                    //do nothing, not found
                }
            }

            plugin.initialize(config);

        } catch (Exception e) {
            CMConsole.logWarning("Loaded '" + plugin.getName() + "' plugin");
            CMConsole.logToFile(e);
        }
    }
}

From source file:com.fuxian.yuncai.common.util.CollectionUtils.java

/**
 * ?./*from   www.j a v a2s  .co  m*/
 */
@SuppressWarnings("rawtypes")
public static boolean isEmpty(Collection collection) {
    return ((collection == null) || collection.isEmpty());
}

From source file:eu.eubrazilcc.lvl.storage.security.PermissionHelper.java

public static final String asOAuthString(final Collection<String> collection, final boolean sort) {
    checkArgument(collection != null && !collection.isEmpty(), "Uninitialized or invalid scope collection");
    final Iterable<String> filtered = filter(transform(collection, new Function<String, String>() {
        @Override/*from   ww  w. j  av  a 2  s.  co m*/
        public String apply(final String permission) {
            return trimToNull(permission);
        }
    }), notNull());
    return on(PERMISSIONS_SEPARATOR).skipNulls()
            .join(sort ? natural().nullsFirst().immutableSortedCopy(filtered) : filtered);
}

From source file:com.github.sakserv.lslock.cli.LockListerCli.java

/**
 * Prints the final output for the locks
 *
 * @param lockDirectory     Directory to recurse for lock files
 * @throws IOException      If the lockdirectory is missing
 *//*  w  w w .j av  a 2s  .  c om*/
public static void printLocks(File lockDirectory, HashMap<Integer, Integer> procLocksContents)
        throws IOException {

    Collection<File> fileList = FileUtils.listFiles(lockDirectory, null, true);

    // If not locks are found, output no locks found
    if (procLocksContents.isEmpty() || fileList.isEmpty()) {
        System.out.println("No locks found for " + lockDirectory);
    } else {
        // Setup the header
        System.out.printf("%-15s %-5s %n", "PID", "PATH");

        // Iterative the files and print the PID and PATH for the lock
        for (File file : fileList) {
            System.out.printf("%-15s %15s %n", procLocksContents.get(getInode(file)), file);
        }
    }
    System.out.println();
}

From source file:com.fuxian.yuncai.common.util.CollectionUtils.java

/**
 * ?.//from   www  . ja v  a  2  s . co  m
 */
@SuppressWarnings("rawtypes")
public static boolean isNotEmpty(Collection collection) {
    return ((collection != null) && !(collection.isEmpty()));
}