Example usage for java.util Collection add

List of usage examples for java.util Collection add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Ensures that this collection contains the specified element (optional operation).

Usage

From source file:com.glaf.jbpm.util.CustomFieldInstantiator.java

private static Object getCollectionValue(Element collectionElement, Collection<Object> collection) {
    Class<?> elementClass = String.class;
    String elementType = collectionElement.attributeValue("element-type");
    if (elementType != null) {
        elementClass = ClassLoaderUtil.classForName(elementType);
    }//  w  ww .  ja  v a  2  s  .  c  om
    Iterator<?> iter = collectionElement.elementIterator();
    while (iter.hasNext()) {
        Element element = (Element) iter.next();
        collection.add(getValue(elementClass, element));
    }
    return collection;
}

From source file:dk.clanie.io.IOUtil.java

/**
 * Adds all files in a directory and it's subdirectories to the supplied Collection.
 * //  w w w  .j a  v  a 2 s.  c  om
 * @param dir
 *            the directory to scan.
 * @param fileCollection
 *            the Collection to update.
 */
public static void addFilesRecursively(File dir, Collection<File> fileCollection) {
    log.debug("Adding files from {}", dir.getPath());
    File[] files = dir.listFiles();
    for (File file : files) {
        if (file.isDirectory())
            addFilesRecursively(file, fileCollection);
        else {
            fileCollection.add(file);
        }
    }
}

From source file:com.salesmanager.core.service.common.impl.ModuleManagerImpl.java

public static Collection<CoreModuleService> getModuleService(String countryIsoCode, int serviceCode) {

    List services = ServicesUtil.getServices(countryIsoCode);

    Collection returnList = new ArrayList();

    if (services != null) {

        Iterator i = services.iterator();
        while (i.hasNext()) {
            CoreModuleService srv = (CoreModuleService) i.next();
            if (srv.getCoreModuleServiceCode() == serviceCode) {
                // return srv;
                returnList.add(srv);
            }//from   w  ww  .  j  a  va  2 s  . com
        }
    }

    return returnList;

}

From source file:eu.medsea.util.EncodingGuesser.java

/**
 * Utility method to get all of the current encoding names, in canonical format, supported by your JVM
 * at the time this is called./*from  w  w  w  .j av a  2s .c  o m*/
 * @return current Collection of canonical encoding names
 */
public static Collection getCanonicalEncodingNamesSupportedByJVM() {
    Collection encodings = new TreeSet();

    SortedMap charSets = Charset.availableCharsets();
    Collection charSetNames = charSets.keySet();
    for (Iterator it = charSetNames.iterator(); it.hasNext();) {
        encodings.add((String) it.next());
    }
    if (log.isDebugEnabled()) {
        log.debug("The following [" + encodings.size() + "] encodings will be used: " + encodings);
    }
    return encodings;
}

From source file:com.eviware.soapui.plugins.PluginProxies.java

@SuppressWarnings("unchecked")
static <T> T createProxyFor(T delegate) {

    if (delegate instanceof JComponent) {
        log.warn("Can't proxy JComponent derived classes");
        return delegate;
    }/*from w  w w . j a v a2 s  . c  om*/

    Collection<Class> interfaces = ClassUtils.getAllInterfaces(delegate.getClass());
    if (interfaces.isEmpty()) {
        // this shouldn't really happen, unless reflection is being used in some odd way
        log.warn("Can't proxy instance of {} because the class doesn't implement any interfaces",
                delegate.getClass());
        return delegate;
    }
    interfaces.add(PluginProxy.class);
    return (T) Proxy.newProxyInstance(PluginProxies.class.getClassLoader(),
            interfaces.toArray(new Class[interfaces.size()]), new DelegatingHandler<T>(delegate));
}

From source file:com.atlassian.theplugin.util.CodeNavigationUtil.java

/**
 * In the collection of provided files looks for those which match vcs url
 *
 * @param psiFiles collection of files to search
 * @param vcsUrl   searched vcs url//from  ww w  . j  a  va  2s.com
 * @param project  project
 * @return collection of found PsiFiles
 */
public static Collection<PsiFile> findPsiFilesWithVcsUrl(final Collection<PsiFile> psiFiles,
        final String vcsUrl, final Project project) {
    Collection<PsiFile> retFiles = new ArrayList<PsiFile>();
    if (psiFiles != null && vcsUrl != null && project != null) {
        for (PsiFile psiFile : psiFiles) {
            String repositoryUrl = VcsIdeaHelper.getRepositoryRootUrlForFile(project, psiFile.getVirtualFile());
            if (repositoryUrl != null && repositoryUrl.equals(vcsUrl) || repositoryUrl == null) {
                retFiles.add(psiFile);
            }
        }
    }

    return retFiles;
}

From source file:com.siemens.sw360.datahandler.common.CommonUtils.java

/**
 * Add a String to a set, if the string is not null
 *///from   w  w w  .j  a  v a 2s . co  m
public static <T> void add(Collection<T> collection, T item) {
    if (collection != null && item != null) {
        collection.add(item);
    }
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.PropertiesTest.java

/**
 * Returns the data for this parameterized test.
 * @return list of all test parameters//  w  w w .  j  ava2  s . c o  m
 * @throws Exception If an error occurs
 */
@Parameters
public static Collection<Object[]> data() throws Exception {
    IE6_ = getProperties(BrowserVersion.INTERNET_EXPLORER_6);
    IE7_ = getProperties(BrowserVersion.INTERNET_EXPLORER_7);
    IE8_ = getProperties(BrowserVersion.INTERNET_EXPLORER_8);
    FF3_ = getProperties(BrowserVersion.FIREFOX_3);
    FF3_6_ = getProperties(BrowserVersion.FIREFOX_3_6);
    Assert.assertEquals(IE6_.size(), IE7_.size());
    Assert.assertEquals(IE6_.size(), IE8_.size());
    Assert.assertEquals(IE6_.size(), FF3_.size());
    Assert.assertEquals(IE6_.size(), FF3_6_.size());
    IE6_SIMULATED_ = getSimulatedProperties(BrowserVersion.INTERNET_EXPLORER_6);
    IE7_SIMULATED_ = getSimulatedProperties(BrowserVersion.INTERNET_EXPLORER_7);
    IE8_SIMULATED_ = getSimulatedProperties(BrowserVersion.INTERNET_EXPLORER_8);
    FF3_SIMULATED_ = getSimulatedProperties(BrowserVersion.FIREFOX_3);
    FF3_6_SIMULATED_ = getSimulatedProperties(BrowserVersion.FIREFOX_3_6);
    Assert.assertEquals(IE6_SIMULATED_.size(), IE7_SIMULATED_.size());
    Assert.assertEquals(IE6_SIMULATED_.size(), IE8_SIMULATED_.size());
    Assert.assertEquals(IE6_SIMULATED_.size(), FF3_SIMULATED_.size());
    Assert.assertEquals(IE6_SIMULATED_.size(), FF3_6_SIMULATED_.size());
    final Collection<Object[]> list = new ArrayList<Object[]>();
    for (final String line : IE6_) {
        final String name = line.substring(0, line.indexOf(':'));
        list.add(new Object[] { name, BrowserVersion.INTERNET_EXPLORER_6 });
        list.add(new Object[] { name, BrowserVersion.INTERNET_EXPLORER_7 });
        list.add(new Object[] { name, BrowserVersion.INTERNET_EXPLORER_8 });
        list.add(new Object[] { name, BrowserVersion.FIREFOX_3 });
        list.add(new Object[] { name, BrowserVersion.FIREFOX_3_6 });
    }
    return list;
}

From source file:com.bluexml.side.form.clazz.utils.ClassDiagramUtils.java

/**
 * Return inherited Clazzs from a class//from w w  w  .  ja  v  a  2  s  . c  o  m
 * 
 * @param cl
 * @return
 */
public static Collection<AbstractClass> getInheritedClazzs(AbstractClass cl) {
    Collection<AbstractClass> listClazz = new ArrayList<AbstractClass>();
    listClazz.add(cl);
    listClazz.addAll(cl.getInheritedClasses());
    return listClazz;
}

From source file:ch.sdi.core.util.ClassUtil.java

/**
 * Lists all types in the given package (recursive) which are annotated by the given annotation and
 * are assignable from given class./*from  w w w  .j  a  va  2s.  c om*/
 * <p>
 * All types which match the criteria are returned, no further checks (interface, abstract, embedded,
 * etc. are performed.
 * <p>
 *
 * @param aClass
 *        the desired (base) class
 * @param aAnnotation
 *        the desired annotation type
 * @param aRoot
 *        the package name where to start the search. Must not be empty. And not start
 *        with 'org.springframework' (cannot parse springs library itself).
 * @return a list of found types
 */
@SuppressWarnings("unchecked")
public static <T> Collection<Class<T>> findCandidatesByAnnotation(Class<T> aClass,
        Class<? extends Annotation> aAnnotation, String aRoot) {
    Collection<Class<T>> result = new ArrayList<Class<T>>();

    Collection<? extends Class<?>> candidates = findCandidatesByAnnotation(aAnnotation, aRoot);

    candidates.stream().peek(c -> myLog.trace("inspecting candidate " + c.getName()))
            .filter(c -> aClass.isAssignableFrom(c))
            .peek(c -> myLog.debug("candidate " + c.getName() + " is of desired type"))
            .forEach(c -> result.add((Class<T>) c));

    return result;

}