List of usage examples for java.util Collection isEmpty
boolean isEmpty();
From source file:com.opengamma.util.test.DbTest.java
private static boolean isScriptPublished() { String zipPath = getZipPath(); if (zipPath == null) { throw new OpenGammaRuntimeException("missing test.sqlZip.path property in test properties file"); }//w w w .j a v a 2 s . c o m File zipScriptPath = new File(DbTool.getWorkingDirectory(), zipPath); boolean result = false; if (zipScriptPath.exists()) { @SuppressWarnings("rawtypes") Collection zipfiles = FileUtils.listFiles(zipScriptPath, new String[] { "zip" }, false); result = !zipfiles.isEmpty(); } return result; }
From source file:com.silverpeas.util.MapUtil.java
/** * Centralizes the map adding that containing list collections * @param <K>/* w w w . ja va 2 s . com*/ * @param <V> * @param setClass * @param map * @param key * @param values * @return */ public static <K, V> Set<V> putAddAllSet(final Class<? extends Set> setClass, Map<K, Set<V>> map, final K key, final Collection<V> values) { Set<V> result = null; if (values != null && !values.isEmpty()) { for (V value : values) { result = putAddSet(setClass, map, key, value); } } else { result = putAddSet(setClass, map, key, null); } // map result (never null) return result; }
From source file:com.silverpeas.util.MapUtil.java
/** * Centralizes the map adding that containing list collections * @param <K>/*w w w . j a va 2 s . co m*/ * @param <V> * @param listClass * @param map * @param key * @param values * @return */ public static <K, V> List<V> putAddAllList(final Class<? extends List> listClass, Map<K, List<V>> map, final K key, final Collection<V> values) { List<V> result = null; if (values != null && !values.isEmpty()) { for (V value : values) { result = putAddList(listClass, map, key, value); } } else { result = putAddList(listClass, map, key, null); } // map result (never null) return result; }
From source file:com.jalios.ejpt.sync.utils.IOUtil.java
public static File findPluginXMLFile(File directory) throws FileNotFoundException { Collection<File> files = FileUtils.listFiles(directory, FileFilterUtils.nameFileFilter(ParseConstants.PLUGIN_XML), TrueFileFilter.INSTANCE); if (!files.isEmpty() && files.size() == 1) { return files.iterator().next(); }//from w ww . j a va 2 s .co m throw new FileNotFoundException("'plugin.xml' not found in " + directory); }
From source file:com.silverpeas.util.MapUtil.java
/** * Centralizes the map adding that containing collections * * @param <K>/* w w w . j a va 2 s . c om*/ * @param <V> * @param map * @param key * @param values * @return */ public static <K, V> Collection<V> putAddAll(final Class<? extends Collection> collectionClass, Map<K, Collection<V>> map, final K key, final Collection<V> values) { Collection<V> result = null; if (values != null && !values.isEmpty()) { for (V value : values) { result = putAdd(collectionClass, map, key, value); } } else { result = putAdd(collectionClass, map, key, null); } // map result (never null) return result; }
From source file:com.doculibre.constellio.plugins.PluginFactory.java
private static void initPluginManager() { if (pm == null) { pm = PluginManagerFactory.createPluginManager(); File classesDir = ClasspathUtils.getClassesDir(); pm.addPluginsFrom(classesDir.toURI()); File pluginsDir = getPluginsDir(); File[] pluginDirs = pluginsDir.listFiles(new FileFilter() { @Override//from w ww . j av a2s. com public boolean accept(File pathname) { boolean accept; if (pathname.isFile()) { accept = false; } else if (DefaultConstellioPlugin.NAME.equals(pathname)) { accept = true; } else { List<String> availablePluginNames = ConstellioSpringUtils.getAvailablePluginNames(); accept = availablePluginNames.contains(pathname.getName()); } return accept; } }); if (pluginDirs == null) { return; } for (File pluginDir : pluginDirs) { // Plugin root dir jars Collection<File> pluginJarFiles = FileUtils.listFiles(pluginDir, new String[] { "jar" }, false); // Accept only one root dir jar File pluginJarFile = pluginJarFiles.isEmpty() ? null : pluginJarFiles.iterator().next(); if (pluginJarFile != null) { URI pluginJarFileURI = pluginJarFile.toURI(); pm.addPluginsFrom(pluginJarFileURI); PluginManagerImpl pmImpl = (PluginManagerImpl) pm; ClassPathManager classPathManager = pmImpl.getClassPathManager(); ClassLoader classLoader = ClassPathManagerUtils.getClassLoader(classPathManager, pluginJarFile); classLoaders.add(classLoader); File pluginLibDir = new File(pluginDir, "lib"); if (pluginLibDir.exists() && pluginLibDir.isDirectory()) { Collection<File> pluginDependencies = FileUtils.listFiles(pluginLibDir, new String[] { "jar" }, false); ClassPathManagerUtils.addJarDependencies(classPathManager, pluginJarFile, pluginDependencies); } } } File webInfDir = ClasspathUtils.getWebinfDir(); File libDir = new File(webInfDir, "lib"); File[] contellioJarFiles = libDir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { boolean accept; if (pathname.isDirectory()) { accept = false; } else { List<String> availablePluginNames = ConstellioSpringUtils.getAvailablePluginNames(); String jarNameWoutExtension = FilenameUtils.removeExtension(pathname.getName()); accept = availablePluginNames.contains(jarNameWoutExtension); } return accept; } }); for (File constellioJarFile : contellioJarFiles) { URI constellioJarFileURI = constellioJarFile.toURI(); pm.addPluginsFrom(constellioJarFileURI); } } }
From source file:de.iteratec.iteraplan.common.GeneralHelper.java
/** * Returns a String made from the concatenation of names of the given Collection of Building Block Types, * separated by the standard {@link Constants#BUILDINGBLOCKSEP}. * @param bbts// www .j a v a 2s . c o m * Collection of Building Block Types * @return Concatenated names of the Building Block Types */ public static String makeConcatenatedNameStringForBbtCollection(Collection<BuildingBlockType> bbts) { if (bbts == null || bbts.isEmpty()) { return " "; } return Joiner.on(Constants.BUILDINGBLOCKSEP) .join(Iterables.transform(bbts, new BBTLocalizedNameFunction())); }
From source file:at.ac.uniklu.mobile.sportal.util.Utils.java
public static String getCSV(Collection<String> collection, String separator) { if (collection == null || collection.isEmpty()) { return null; }//from w w w. j a v a 2 s.co m StringBuffer sb = new StringBuffer(); for (String s : collection) { sb.append(separator).append(s); } return sb.toString(); }
From source file:de.iteratec.iteraplan.common.GeneralHelper.java
/** * Returns a set of integers containing the IDs of the given collection of {@link IdEntity}s. * //from w w w . j a v a2 s .c om * @param col * A set of {@link IdEntity}s. * * @return * A set of integers containing the IDs of the given collection. If the collection is * {@code null} or empty, an empty set is returned. */ public static Set<Integer> createIdSetFromIdEntities(Collection<? extends IdEntity> col) { if (col == null || col.isEmpty()) { return Sets.newHashSet(); } EntityToIdFunction<IdEntity, Integer> entityToIdFunction = new EntityToIdFunction<IdEntity, Integer>(); Iterable<Integer> ids = Iterables.transform(col, entityToIdFunction); return Sets.newHashSet(ids); }
From source file:de.iteratec.iteraplan.common.GeneralHelper.java
/** * Returns a String made from the concatenation of names of the given Collection of Building Blocks, * separated by the standard {@link Constants#BUILDINGBLOCKSEP}. * @param bbs//from w ww .jav a 2 s. co m * Collection of Building Blocks * @return Concatenated names of the Building Blocks */ public static String makeConcatenatedNameStringForBbCollection(Collection<? extends BuildingBlock> bbs) { if (bbs == null || bbs.isEmpty()) { return " "; } Function<BuildingBlock, String> toNameFuntion = new Function<BuildingBlock, String>() { public String apply(BuildingBlock bb) { return bb.getNonHierarchicalName(); } }; return Joiner.on(Constants.BUILDINGBLOCKSEP).join(Iterables.transform(bbs, toNameFuntion)); }