List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:fr.esiea.windmeal.test.integration.dao.mongo.DaoTest.java
@Before public void setUp() throws Exception { user.generateId();//from w ww. j a v a 2 s. com provider.generateId(); order.generateId(); menu.generateId(); Meal meal = new Meal(); meal.generateId(); meal.setDescription("desc"); HashSet<MealOrder> mealOrders = new HashSet<MealOrder>(); MealOrder mealOrder = new MealOrder(); meal.generateId(); mealOrder.setNumber(3); mealOrders.add(mealOrder); order.setMeals(mealOrders); }
From source file:de.hybris.platform.test.PKTest.java
@Test public void samePK() throws Exception { final HashSet s = new HashSet(); for (int i = 0; i < 200000; i++) { final PK p = PK.createUUIDPK(101); if (!s.add(p)) { fail("PK " + p + " was already in the map"); }// w ww .j a v a2 s. co m } }
From source file:edu.cornell.mannlib.vitro.webapp.sparql.GetClazzDataProperties.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.USE_MISCELLANEOUS_PAGES.ACTION)) { return;/*from ww w .j a v a 2s . c o m*/ } VitroRequest vreq = new VitroRequest(request); String vClassURI = vreq.getParameter("vClassURI"); if (vClassURI == null || vClassURI.trim().equals("")) { return; } String respo = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; respo += "<options>"; // Add rdfs:label to the list respo += "<option>" + "<key>" + "label" + "</key>" + "<value>" + "http://www.w3.org/2000/01/rdf-schema#label" + "</value>" + "</option>"; DataPropertyDao ddao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao(); Collection<DataProperty> dataProps = ddao.getDataPropertiesForVClass(vClassURI); Iterator<DataProperty> dataPropIt = dataProps.iterator(); HashSet<String> dpropURIs = new HashSet<String>(); while (dataPropIt.hasNext()) { DataProperty dp = dataPropIt.next(); if (!(dpropURIs.contains(dp.getURI()))) { dpropURIs.add(dp.getURI()); DataProperty dprop = (DataProperty) ddao.getDataPropertyByURI(dp.getURI()); if (dprop != null) { respo += "<option>" + "<key>" + dprop.getLocalName() + "</key>" + "<value>" + dprop.getURI() + "</value>" + "</option>"; } } } respo += "</options>"; response.setContentType("text/xml"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); out.println(respo); out.flush(); out.close(); }
From source file:net.mybox.mybox.Server.java
public void updateMultiMap(String id, Integer handle) { if (multiClientMap.containsKey(id)) { HashSet<Integer> thisMap = multiClientMap.get(id); thisMap.add(handle); multiClientMap.put(id, thisMap); // should overwrite the old map } else {/*from ww w. java 2 s . co m*/ HashSet<Integer> thisMap = new HashSet<Integer>(); thisMap.add(handle); multiClientMap.put(id, thisMap); } }
From source file:gr.cti.android.experimentation.controller.api.SmartphoneController.java
private Set<BadgeDTO> newBadgeDTOSet(Set<Badge> byExperimentIdAndDeviceId) { final HashSet<BadgeDTO> badgeSet = new HashSet<BadgeDTO>(); for (final Badge badge : byExperimentIdAndDeviceId) { badgeSet.add(newBadgeDTO(badge)); }/*from w ww . j ava2 s. co m*/ return badgeSet; }
From source file:com.thoughtworks.studios.journey.models.ActionCorrelationCalculation.java
private Set<String> collectActions(Iterable<Node> journeys) { HashSet<String> result = new HashSet<>(); for (Node journey : journeys) { for (Node event : app.journeys().events(journey)) { result.add(app.events().getActionLabel(event)); }//from ww w . j a v a2 s. co m } return result; }
From source file:fi.helsinki.lib.simplerest.RootCommunitiesResource.java
private Representation errorUnallowedMethod(String unallowedMethod) { HashSet<Method> allowed = new HashSet(); allowed.add(Method.GET); allowed.add(Method.POST);//from w ww . j a va 2 s . co m setAllowedMethods(allowed); return error(null, "Root communities resource does not allow " + unallowedMethod + " method.", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); }
From source file:org.openscore.lang.tools.verifier.SlangContentVerifierTest.java
@Test public void testCompileValidSlangFileWithDependencies() throws Exception { URI resource = getClass().getResource("/dependencies").toURI(); Set<String> flowDependencies = new HashSet<>(); flowDependencies.add("dependencies.dependency"); Flow emptyFlowExecutable = new Flow(null, null, null, "dependencies", "empty_flow", null, null, null, flowDependencies);//from ww w . ja v a 2 s . c om Mockito.when(slangCompiler.preCompile(new SlangSource("", "empty_flow.sl"))) .thenReturn(emptyFlowExecutable); Flow dependencyExecutable = new Flow(null, null, null, "dependencies", "dependency", null, null, null, new HashSet<String>()); Mockito.when(slangCompiler.preCompile(new SlangSource("", "dependency.sl"))) .thenReturn(dependencyExecutable); HashSet<Executable> dependencies = new HashSet<>(); dependencies.add(dependencyExecutable); Mockito.when(scoreCompiler.compile(emptyFlowExecutable, dependencies)).thenReturn(emptyCompilationArtifact); Mockito.when(scoreCompiler.compile(dependencyExecutable, new HashSet<Executable>())) .thenReturn(emptyCompilationArtifact); int numberOfCompiledSlangFiles = slangContentVerifier.verifyAllSlangFilesInDirAreValid(resource.getPath()); Assert.assertEquals("Did not compile all Slang files. Expected to compile: 2, but compiled: " + numberOfCompiledSlangFiles, numberOfCompiledSlangFiles, 2); }
From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java
private List<Individual> removeIndividualsAlreadyInRange(List<Individual> indiviuals, List<ObjectPropertyStatement> stmts) { log.trace(//from www. ja v a 2s . c o m "starting to check for duplicate range individuals in OptionsForPropertyTag.removeIndividualsAlreadyInRange() ..."); HashSet<String> range = new HashSet<String>(); for (ObjectPropertyStatement ops : stmts) { if (ops.getPropertyURI().equals(getPredicateUri())) range.add(ops.getObjectURI()); } int removeCount = 0; ListIterator<Individual> it = indiviuals.listIterator(); while (it.hasNext()) { Individual ind = it.next(); if (range.contains(ind.getURI())) { it.remove(); ++removeCount; } } log.trace("removed " + removeCount + " duplicate range individuals"); return indiviuals; }
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 av a2 s . c o m*/ } 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!"); }