List of usage examples for java.util Iterator remove
default void remove()
From source file:edu.pdx.konstan2.PortlandLive.responseParserFactory.java
public void parseArrivals(String response, HashMap<String, Arrival> sMap) { try {//from w w w .ja v a 2s.c o m JSONParser parser = new JSONParser(); JSONObject jobj = (JSONObject) parser.parse(response.toString()); JSONObject v = (JSONObject) jobj.get("resultSet"); JSONArray arr = (JSONArray) v.get("arrival"); Iterator<JSONObject> iter = arr.iterator(); while (iter.hasNext()) { Arrival t = new Arrival(iter.next()); sMap.put(t.id, t); iter.remove(); } } catch (Exception e) { Log.d("exception", e.toString()); } }
From source file:net.kaczmarzyk.spring.data.jpa.domain.EqualEnum.java
private List<Enum<?>> findMatchingEnumConstants(Class<? extends Enum<?>> enumClass) { List<String> searchedNamesCopy = new ArrayList<>(Arrays.asList(searchedNames)); List<Enum<?>> matchingEnumConstants = new ArrayList<>(); Enum<?>[] enumConstants = enumClass.getEnumConstants(); for (Enum<?> enumConstant : enumConstants) { Iterator<String> i = searchedNamesCopy.iterator(); while (i.hasNext()) { if (enumConstant.name().equals(i.next())) { matchingEnumConstants.add(enumConstant); i.remove(); }/*from www. j ava2 s . c o m*/ } } if (searchedNamesCopy.size() > 0) { throw new IllegalArgumentException( "The following enum constants do not exists: " + StringUtils.join(searchedNamesCopy, ", ")); } return matchingEnumConstants; }
From source file:samza.samza_test.SamzaTestScan.java
private void cleanMap() { Iterator it = top.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Integer> pair = (Map.Entry<String, Integer>) it.next(); if (pair.getValue() == 1) { it.remove(); }//from w w w.j a va 2s . c o m } }
From source file:au.org.ala.delta.directives.validation.ItemDescriptionsValidator.java
protected void checkForInvalidDescription(Iterator<?> descriptions, DeltaDataSet dataSet, List<String> invalidDescriptions, String description) { Item item = dataSet.itemForDescription(description); if (item == null) { invalidDescriptions.add(description); descriptions.remove(); }//from w w w . ja v a 2 s.c o m }
From source file:org.cruk.genologics.api.jaxb.URIAdapter.java
/** * Look for a parameter called "state" and remove it from the list if * it is found.//from www .ja va2s . c o m * * @param terms The name value pair terms. */ private void removeStateParameter(List<NameValuePair> terms) { if (REMOVE_STATE) { Iterator<NameValuePair> iter = terms.iterator(); while (iter.hasNext()) { if ("state".equals(iter.next().getName())) { iter.remove(); } } } }
From source file:com.mcreations.usb.windows.JavaxUsb.java
/** * Check for the existence of a device in the given <code>connected</code> and * <code>disconnected</code> lists. * <p>//from w ww .j a v a2s.c o m * If the device exists, the existing device is removed from the disconnected list and the new * device added to the connected list: that means, that the device was disconnected and then * reconnected, because the main loop in {@link JavaxUsb#topologyUpdater} only calls * {@link JavaxUsb#buildDevice} in case of changes in the topology (Libusb.usb_find_devices != 0). * <p> * If the device is new, it is added to the connected list and returned. If the new device replaces * an existing device, the old device is retained in the disconnected list, and the new device is returned. * @param hub The parent UsbHubImp. * @param device The UsbDeviceImp to add. * @param currentDevices - the list of devices that were connected before this call to topology update * @param disconnected The List of all devices that can possibly disconnected * @param connected The List of connected devices that are newely connected * @return The new UsbDeviceImp or existing UsbDeviceImp. */ private static void checkUsbDeviceImp(UsbHubImp hub, UsbDeviceImp device, List currentDevices, List connected) { boolean found = false; String method = "checkUsbDeviceImp"; // look for this devices in the current device list, if found remove from the list // because later, the remaining items in current device list will be removed. Iterator iterator = currentDevices.iterator(); while (iterator.hasNext()) { UsbDeviceImp usbDeviceFromList = (UsbDeviceImp) iterator.next(); if (isUsbDevicesEqual(usbDeviceFromList, device)) { iterator.remove(); found = true; } } // If the device was not found in the list, it must be new. Add it to the connected list if (!found) { if (log.isDebugEnabled()) log.debug(method + " found new device"); connected.add(device); attachParentUsbPort(hub, device); } }
From source file:org.cloudfoundry.identity.uaa.login.feature.InvitationsIT.java
@Test public void testSendInvite() throws Exception { int randomInt = new SecureRandom().nextInt(); String userEmail = "user" + randomInt + "@example.com"; int receivedEmailSize = simpleSmtpServer.getReceivedEmailSize(); signIn(testAccounts.getUserName(), testAccounts.getPassword()); webDriver.findElement(By.linkText("Invite Users")).click(); assertEquals("Send an invite", webDriver.findElement(By.tagName("h1")).getText()); webDriver.findElement(By.name("email")).sendKeys(userEmail); webDriver.findElement(By.xpath("//input[@value='Send invite']")).click(); assertEquals("Invite sent", webDriver.findElement(By.tagName("h1")).getText()); assertEquals(receivedEmailSize + 1, simpleSmtpServer.getReceivedEmailSize()); Iterator receivedEmail = simpleSmtpServer.getReceivedEmail(); SmtpMessage message = (SmtpMessage) receivedEmail.next(); receivedEmail.remove(); assertEquals(userEmail, message.getHeaderValue("To")); assertThat(message.getBody(), containsString("Accept Invite")); String link = testClient.extractLink(message.getBody()); assertTrue(link.contains("/invitations/accept")); webDriver.get(link);// w ww .jav a 2 s . com assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText()); webDriver.findElement(By.name("password")).sendKeys("secret"); webDriver.findElement(By.name("password_confirmation")).sendKeys("secret"); webDriver.findElement(By.xpath("//input[@value='Create account']")).click(); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?")); webDriver.findElement(By.xpath("//*[text()='" + userEmail + "']")).click(); webDriver.findElement(By.linkText("Sign Out")).click(); webDriver.findElement(By.name("username")).sendKeys(userEmail); webDriver.findElement(By.name("password")).sendKeys("secret"); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?")); }
From source file:com.publicuhc.uhcaddons.teammanager.commands.RandomTeamsCommand.java
@CommandMethod("randomteams") @PermissionRestriction(RANDOM_TEAMS_PERMISSION) @CommandOptions("n") public void onRandomTeams(OptionSet set, CommandSender sender, Integer amount) { if (amount < 1) { translate.sendMessage("greater than zero", sender); return;//from w w w . java 2s . c om } List<Player> players = Lists.newArrayList(Bukkit.getOnlinePlayers()); Collections.shuffle(players); Iterator<Player> playerIterator = players.iterator(); while (playerIterator.hasNext()) { if (scoreboard.getPlayerTeam(playerIterator.next()) != null) { playerIterator.remove(); } } if (amount <= players.size()) { translate.sendMessage("not enough players online", sender, players.size()); return; } List<List<Player>> splitup = split(players, amount); for (List<Player> teamGroup : splitup) { Team newTeam = manager.getNewTeam(true); Collection<String> playerNames = Lists.newArrayList(); for (OfflinePlayer p : teamGroup) { playerNames.add(p.getName()); } for (Player p : teamGroup) { newTeam.addPlayer(p); } manager.sendToTeamTranslated(newTeam, "your team", Joiner.on(",").join(playerNames)); } translate.sendMessage("created", sender, splitup.size()); }
From source file:com.evolveum.midpoint.prism.xjc.PrismReferenceArrayList.java
/** * JAXB unmarshaller is calling clear() on lists even though they were just * created. As the references should be visible as two JAXB fields, clearing one * of them will also clear the other. Therefore we need this hack. Calling clear() * will only clear the values that naturally "belong" to the list. */// w ww . j a v a2 s . co m @Override public void clear() { List<PrismReferenceValue> values = reference.getValues(); if (values == null) { return; } Iterator<PrismReferenceValue> iterator = values.iterator(); while (iterator.hasNext()) { PrismReferenceValue value = iterator.next(); if (willClear(value)) { iterator.remove(); } } }
From source file:com.avanza.ymer.FakeDocumentCollection.java
@Override public void update(DBObject newVersion) { Iterator<DBObject> it = collection.iterator(); while (it.hasNext()) { DBObject dbObject = it.next();/*from w w w. j a v a 2 s . c o m*/ if (dbObject.get("_id").equals(newVersion.get("_id"))) { it.remove(); collection.add(newVersion); return; } } // No object found, do insert insert(newVersion); }