Example usage for java.util LinkedHashSet addAll

List of usage examples for java.util LinkedHashSet addAll

Introduction

In this page you can find the example usage for java.util LinkedHashSet addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:de.qaware.chronix.solr.type.metric.SolrDocumentBuilder.java

/**
 * Merges to sets of time series attributes.
 * The result is set for each key holding the values.
 * If the other value is a collection, than all values
 * of the collection are added instead of the collection object.
 *
 * @param merged     the merged attributes
 * @param attributes the attributes of the other time series
 *//*  w w w.  j av  a  2 s .  c o m*/
private static void merge(Map<String, Object> merged, Map<String, Object> attributes) {

    for (HashMap.Entry<String, Object> newEntry : attributes.entrySet()) {

        String key = newEntry.getKey();

        //we ignore the version in the result
        if (key.equals("_version_")) {
            continue;
        }

        if (!merged.containsKey(key)) {
            merged.put(key, new LinkedHashSet());
        }

        LinkedHashSet values = (LinkedHashSet) merged.get(key);
        Object value = newEntry.getValue();

        //Check if the value is a collection.
        //If it is a collection we add all values instead of adding a collection object
        if (value instanceof Collection && !values.contains(value)) {
            values.addAll((Collection) value);
        } else if (!values.contains(value)) {
            //Otherwise we have a single value or an array.
            values.add(value);
        }
        //otherwise we ignore the value
    }
}

From source file:com.janrain.backplane2.server.Scope.java

/**
 * Add the scopes in the second map to the first.
 *///from  ww w  .  ja  v a2s .  c om
public static void addScopes(Map<BackplaneMessage.Field, LinkedHashSet<String>> first,
        Map<BackplaneMessage.Field, LinkedHashSet<String>> second) {
    for (BackplaneMessage.Field field : second.keySet()) {
        LinkedHashSet<String> values = first.get(field);
        if (values == null) {
            values = new LinkedHashSet<String>();
            first.put(field, values);
        }
        values.addAll(second.get(field));
    }
}

From source file:com.buaa.cfs.net.DNS.java

/**
 * @param nif network interface to get addresses for
 *
 * @return set containing addresses for each subinterface of nif, see below for the rationale for using an ordered
 * set/* ww  w  . j a  v a 2 s.  c o  m*/
 */
private static LinkedHashSet<InetAddress> getSubinterfaceInetAddrs(NetworkInterface nif) {
    LinkedHashSet<InetAddress> addrs = new LinkedHashSet<InetAddress>();
    Enumeration<NetworkInterface> subNifs = nif.getSubInterfaces();
    while (subNifs.hasMoreElements()) {
        NetworkInterface subNif = subNifs.nextElement();
        addrs.addAll(Collections.list(subNif.getInetAddresses()));
    }
    return addrs;
}

From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java

private static void initGroups(LinkedHashSet<String> groups, Map<File, String> fileToGroup,
        LinkedHashMap<String, Set<File>> groupToFile) {
    groups.addAll(fileToGroup.values());
    for (String group : groups) {
        for (File key : fileToGroup.keySet()) {
            if (fileToGroup.get(key).equals(group)) {
                if (groupToFile.containsKey(group)) {
                    Set<File> s = groupToFile.get(group);
                    s.add(key);//from   www . j  ava2s.  c  om
                } else {
                    Set<File> s = new LinkedHashSet<>();
                    s.add(key);
                    groupToFile.put(group, s);
                }

            }
        }
    }
}

From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java

private static void initSampleGroups(LinkedHashSet<String> sampleGroups, Map<File, String> fileToSampleGroup,
        LinkedHashMap<String, Set<File>> groupToFile) {
    sampleGroups.addAll(fileToSampleGroup.values());
    for (String sampleGroup : sampleGroups) {
        for (File key : fileToSampleGroup.keySet()) {
            if (fileToSampleGroup.get(key).equals(sampleGroup)) {
                if (groupToFile.containsKey(sampleGroup)) {
                    Set<File> s = groupToFile.get(sampleGroup);
                    s.add(key);/*from   w  ww.  ja v a  2 s  . c o m*/
                } else {
                    Set<File> s = new LinkedHashSet<>();
                    s.add(key);
                    groupToFile.put(sampleGroup, s);
                }

            }
        }
    }
}

From source file:gov.nih.nci.caarray.dao.SampleDaoImpl.java

private static String getJoinClause(boolean count,
        JoinableSortCriterion<? extends AbstractBioMaterial> sortCrit,
        BiomaterialSearchCategory... categories) {
    LinkedHashSet<String> joins = new LinkedHashSet<String>();
    for (BiomaterialSearchCategory category : categories) {
        joins.addAll(Arrays.asList(category.getJoins()));
    }//from w ww . j av  a 2 s  .c o m
    return generateJoinClause(count, sortCrit, joins);
}

From source file:de.qaware.chronix.solr.query.analysis.SolrDocumentBuilder.java

/**
 * Merges to sets of time series attributes.
 * The result is set for each key holding the values.
 * If the other value is a collection, than all values
 * of the collection are added instead of the collection object.
 *
 * @param merged     the merged attributes
 * @param attributes the attributes of the other time series
 *//*from   ww w. j ava2  s . c om*/
private static void merge(Map<String, Object> merged, Map<String, Object> attributes) {

    for (HashMap.Entry<String, Object> newEntry : attributes.entrySet()) {

        String key = newEntry.getKey();

        //we ignore the version in the result
        if (key.equals(ChronixQueryParams.SOLR_VERSION_FIELD)) {
            continue;
        }

        if (!merged.containsKey(key)) {
            merged.put(key, new LinkedHashSet());
        }

        LinkedHashSet values = (LinkedHashSet) merged.get(key);
        Object value = newEntry.getValue();

        //Check if the value is a collection.
        //If it is a collection we add all values instead of adding a collection object
        if (value instanceof Collection && !values.contains(value)) {
            values.addAll((Collection) value);
        } else if (!values.contains(value)) {
            //Otherwise we have a single value or an array.
            values.add(value);
        }
        //otherwise we ignore the value
    }
}

From source file:gov.nih.nci.caarray.dao.ProjectDaoImpl.java

private static String getJoinClause(SearchCategory... categories) {
    final LinkedHashSet<String> joins = new LinkedHashSet<String>();
    for (final SearchCategory category : categories) {
        joins.addAll(Arrays.asList(category.getJoins()));
    }/*from  w w w . ja  v a  2 s  .  co  m*/
    final StringBuffer sb = new StringBuffer();
    for (final String table : joins) {
        sb.append(" LEFT JOIN ").append(table);
    }
    return sb.toString();
}

From source file:com.pimp.companionforband.utils.jsontocsv.writer.CSVWriter.java

private LinkedHashSet<String> collectHeaders(List<LinkedHashMap<String, String>> flatJson) {
    LinkedHashSet<String> headers = new LinkedHashSet<>();
    for (LinkedHashMap<String, String> map : flatJson) {
        headers.addAll(map.keySet());
    }//from ww  w .jav  a 2 s . c  o  m
    return headers;
}

From source file:pt.lsts.neptus.plugins.trex.TrexTimelinePanel.java

public final Collection<String> getSeriesNames() {
    LinkedHashSet<String> series = new LinkedHashSet<>();
    series.addAll(this.series.keySet());
    Vector<String> col = new Vector<>();
    col.addAll(series);/*from w w w.  j  a v  a  2  s. co m*/
    Collections.sort(col);
    return col;
}