Example usage for java.util HashSet addAll

List of usage examples for java.util HashSet addAll

Introduction

In this page you can find the example usage for java.util HashSet 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:org.hyperic.hq.ui.action.resource.common.monitor.alerts.config.RemoveUsersAction.java

/**
 * Handles the actual work of removing users from the action.
 *///from  w  w w.  ja  v a 2 s.com
protected ActionForward handleRemove(ActionMapping mapping, HttpServletRequest request,
        Map<String, Object> params, Integer sessionID, ActionValue action, EmailActionConfig ea, EventsBoss eb,
        RemoveNotificationsForm rnForm) throws Exception {

    Integer[] users = rnForm.getUsers();
    if (null != users) {
        log.debug("users.length=" + users.length);
        HashSet<Object> storedUsers = new HashSet<Object>();
        storedUsers.addAll(ea.getUsers());
        for (int x = 0; x < users.length; ++x) {
            storedUsers.remove(users[x]);
        }
        ea.setNames(StringUtil.iteratorToString(storedUsers.iterator(), ","));
        action.setConfig(ea.getConfigResponse().encode());
        eb.updateAction(sessionID.intValue(), action);
    }

    return returnSuccess(request, mapping, params);
}

From source file:org.hyperic.hq.ui.action.resource.common.monitor.alerts.config.RemoveOthersAction.java

/**
 * Handles the actual work of removing emails from the action.
 *///from   w  ww  . j ava  2 s .  com
protected ActionForward handleRemove(ActionMapping mapping, HttpServletRequest request,
        Map<String, Object> params, Integer sessionID, ActionValue action, EmailActionConfig ea, EventsBoss eb,
        RemoveNotificationsForm rnForm) throws Exception {
    String[] emails = rnForm.getEmails();
    if (null != emails) {
        log.debug("emails.length=" + emails.length);
        HashSet<Object> storedEmails = new HashSet<Object>();
        storedEmails.addAll(ea.getUsers());
        log.debug("storedEmails (pre): " + storedEmails);
        for (int i = 0; i < emails.length; ++i) {
            storedEmails.remove(emails[i]);
        }
        log.debug("storedEmails (post): " + storedEmails);
        ea.setNames(StringUtil.iteratorToString(storedEmails.iterator(), ","));
        action.setConfig(ea.getConfigResponse().encode());
        eb.updateAction(sessionID.intValue(), action);
    }

    return returnSuccess(request, mapping, params);
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.NewResourcePreprocessor.java

private void replaceNewURIs() {
    if (editConfiguration.isUpdate()) {
        List<String> urisOnForm = editConfiguration.getUrisOnform();
        HashSet<String> configUrisOnForm = new HashSet<String>();
        configUrisOnForm.addAll(urisOnForm);
        for (String varName : forceNewURIsList) {
            //No value submitted for uri, so new resource needs to be created
            //and old one should not be used
            if (configUrisOnForm.contains(varName) && !urisFromForm.containsKey(varName)) {
                submission.addUriToForm(editConfiguration, varName,
                        new String[] { EditConfigurationConstants.NEW_URI_SENTINEL });
            }// ww  w  .j  a  v a  2s. com
        }
    }
}

From source file:org.atemsource.atem.impl.common.IncomingManyRelation.java

@Override
public Set<J> getValue(Object entity) {
    if (attributeQuery == null) {
        throw new UnsupportedOperationException("this incomingRelation is not readable");
    }/*from   ww  w . j  ava2 s.c  o  m*/
    HashSet<J> hashSet = new HashSet<J>();
    hashSet.addAll((Collection<? extends J>) attributeQuery.getResult(entity));
    return hashSet;
}

From source file:org.codice.alliance.security.banner.marking.MarkingExtractor.java

protected List<Serializable> dedupedList(Collection<? extends Serializable> collA,
        Collection<? extends Serializable> collB) {
    HashSet<Serializable> union = new HashSet<>(collA);
    union.addAll(collB);
    return ImmutableList.copyOf(union);
}

From source file:org.apache.beam.runners.apex.examples.WordCountTest.java

@Test
public void testWordCountExample() throws Exception {
    PipelineOptionsFactory.register(WordCountOptions.class);
    WordCountOptions options = TestPipeline.testingPipelineOptions().as(WordCountOptions.class);
    options.setRunner(TestApexRunner.class);
    options.setApplicationName("StreamingWordCount");
    String inputFile = WordCountTest.class.getResource("/words.txt").getFile();
    options.setInputFile(new File(inputFile).getAbsolutePath());
    String outputFilePrefix = "target/wordcountresult.txt";
    options.setOutput(outputFilePrefix);
    WordCountTest.main(TestPipeline.convertToArgs(options));

    File outFile1 = new File(outputFilePrefix + "-00000-of-00002");
    File outFile2 = new File(outputFilePrefix + "-00001-of-00002");
    Assert.assertTrue(outFile1.exists() && outFile2.exists());
    HashSet<String> results = new HashSet<>();
    results.addAll(FileUtils.readLines(outFile1));
    results.addAll(FileUtils.readLines(outFile2));
    HashSet<String> expectedOutput = Sets.newHashSet("foo - 5 @ 294247-01-09T04:00:54.775Z",
            "bar - 5 @ 294247-01-09T04:00:54.775Z");
    Assert.assertEquals("expected output", expectedOutput, results);
}

From source file:it.iit.genomics.cru.structures.bridges.bridges.UniprotkbUtilsTest.java

public void testVarSplice() throws BridgesRemoteAccessException {
    String uniprotAc = "O14746";

    String[] uniprotAcs = { uniprotAc };

    ArrayList<String> uniprotAcsCollection = new ArrayList<>();
    uniprotAcsCollection.addAll(Arrays.asList(uniprotAcs));

    HashMap<String, MoleculeEntry> entries = UniprotkbUtils.getInstance("9606")
            .getUniprotEntriesFromUniprotAccessions(uniprotAcsCollection);
    System.out.println(entries.get(uniprotAc).getVarSpliceAC("NM_198253"));
    //System.out.println(entries.get(uniprotAc).getVarSpliceAC("NM_001145339.2")); 

    HashSet<String> geneIds = new HashSet<>();
    geneIds.addAll(entries.get(uniprotAc).getGeneNames());
    geneIds.addAll(entries.get(uniprotAc).getRefseqs());
    geneIds.addAll(entries.get(uniprotAc).getEnsemblGenes());
    System.out.println("GeneIds: " + StringUtils.join(geneIds, ", "));

    System.out.println(entries.get(uniprotAc).getVarSpliceAC("NM_198253"));
    System.out.println(entries.get(uniprotAc).getSequence("NM_198253"));

    Assert.assertEquals(uniprotAc, entries.get(uniprotAc).getVarSpliceAC("NM_198253"));
    Assert.assertEquals(uniprotAc, entries.get(uniprotAc).getSequence("NM_198253").getSequence());

}

From source file:jasima.core.util.ExperimentTest.java

/**
 * Checks whether key sets of actual and expected results are the same.
 * //from w ww .j a v  a  2 s  .  c  om
 * @param resActual
 *            The map of results actually obtained.
 * @param resExpected
 *            The map of expected results.
 */
protected void checkKeySets(Map<String, Object> resActual, Map<String, Object> resExpected) {
    Set<String> keysAct = new HashSet<String>(resActual.keySet());
    Set<String> keysExp = new HashSet<String>(resExpected.keySet());

    HashSet<String> all = new HashSet<String>();
    all.addAll(keysAct);
    all.addAll(keysExp);

    HashSet<String> onlyExp = new HashSet<String>(all);
    onlyExp.removeAll(keysAct);

    HashSet<String> onlyAct = new HashSet<String>(all);
    onlyAct.removeAll(keysExp);
    errorCollector.checkThat("key sets should be equal.\n" + "keys missing in actual result map: " + onlyExp
            + ";\n" + "keys only in actual result map: " + onlyAct, keysAct, is(keysExp));
}

From source file:biomine.bmvis2.pipeline.EdgeGoodnessHider.java

public void doOperation(VisualGraph g) throws GraphOperationException {
    HashSet<VisualEdge> hiddenEdges = new HashSet<VisualEdge>();
    hiddenEdges.addAll(g.getHiddenEdges());
    for (VisualEdge e : g.getAllEdges()) {
        if (e.getGoodness() < limit) {
            hiddenEdges.add(e);//from ww  w.  j  a v a2  s  . c  om
        }
    }
    ArrayList<VisualNode> hiddenNodes = new ArrayList();
    for (VisualNode n : g.getNodes()) {
        int edgeCount = 0;
        for (VisualEdge e : n.getEdges()) {
            if (!hiddenEdges.contains(e))
                edgeCount++;
        }
        if (edgeCount == 0) {
            hiddenNodes.add(n);
        }
    }
    g.hideNodes(hiddenNodes);
    g.hideEdges(hiddenEdges);
    System.out.println("edgeGoodness update!");
}

From source file:com.parse.ParseRemoveOperation.java

@Override
public ParseFieldOperation mergeWithPrevious(ParseFieldOperation previous) {
    if (previous == null) {
        return this;
    } else if (previous instanceof ParseDeleteOperation) {
        return new ParseSetOperation(objects);
    } else if (previous instanceof ParseSetOperation) {
        Object value = ((ParseSetOperation) previous).getValue();
        if (value instanceof JSONArray || value instanceof List) {
            return new ParseSetOperation(this.apply(value, null));
        } else {/*  w w w. ja va  2s.c o  m*/
            throw new IllegalArgumentException("You can only add an item to a List or JSONArray.");
        }
    } else if (previous instanceof ParseRemoveOperation) {
        HashSet<Object> result = new HashSet<>(((ParseRemoveOperation) previous).objects);
        result.addAll(objects);
        return new ParseRemoveOperation(result);
    } else {
        throw new IllegalArgumentException("Operation is invalid after previous operation.");
    }
}