List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:de.xaniox.heavyspleef.addon.access.CommandManagerAccess.java
public void unregisterSpleefCommand(Class<?> clazz) { for (Set<Class<?>> set : registeredAddOnCommands.values()) { if (set.contains(clazz)) { set.remove(clazz); delegate.unregisterSpleefCommand(clazz); return; }/* w w w. ja v a2s .c o m*/ } throw new IllegalArgumentException("Command class " + clazz.getName() + " is not registered"); }
From source file:org.os890.ds.addon.spring.impl.CdiAwareBeanFactoryPostProcessor.java
private BeanDefinition createSpringBeanDefinition(Bean<?> cdiBean) throws Exception { AbstractBeanDefinition beanDefinition = new GenericBeanDefinition(); Set<Type> beanTypes = new HashSet<Type>(cdiBean.getTypes()); beanTypes.remove(Object.class); beanTypes.remove(Serializable.class); Type beanType = beanTypes.size() == 1 ? beanTypes.iterator().next() : null; if (beanType instanceof Class) { //to support producers beanDefinition.setBeanClass((Class) beanType); } else { //fallback since spring doesn't support multiple types beanDefinition.setBeanClass(cdiBean.getBeanClass()); }/* ww w .ja v a2 s. c o m*/ beanDefinition.setScope(CdiSpringScope.class.getName()); for (Annotation qualifier : cdiBean.getQualifiers()) { if (Any.class.equals(qualifier.annotationType()) || Default.class.equals(qualifier.annotationType())) { continue; } //currently only simple qualifiers are supported AutowireCandidateQualifier springQualifier = new AutowireCandidateQualifier(qualifier.annotationType()); for (Method annotationMethod : qualifier.annotationType().getDeclaredMethods()) { if (!annotationMethod.isAnnotationPresent(Nonbinding.class)) { springQualifier.setAttribute(annotationMethod.getName(), annotationMethod.invoke(qualifier)); } } beanDefinition.addQualifier(springQualifier); } beanDefinition.setLazyInit(true); return beanDefinition; }
From source file:Main.java
public static Set<String> compareXmlFiles(String firstFolderPath, String secondFolderPath, boolean outConsole) { Set<String> identicalFiles = new HashSet<String>(); File firstFolder = new File(firstFolderPath); File secondFolder = new File(secondFolderPath); Map<String, File> firstFileMap = new HashMap<String, File>(); Map<String, File> secondFileMap = new HashMap<String, File>(); traverseFolder(firstFileMap, firstFolder, firstFolder); traverseFolder(secondFileMap, secondFolder, secondFolder); // temporarily - comparison by MD5 instead of XML parsing SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = null;/* www .j av a 2 s . c o m*/ try { saxParser = factory.newSAXParser(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } System.out.println("Parser: " + saxParser); Set<String> sourceKeys = firstFileMap.keySet(); Set<String> destKeys = secondFileMap.keySet(); for (String key1 : sourceKeys) { File file1 = firstFileMap.get(key1); File file2 = secondFileMap.get(key1); if (file1 != null && file2 != null) { try { String node1 = calculateMd5Checksum(file1.getCanonicalPath()); String node2 = calculateMd5Checksum(file2.getCanonicalPath()); // System.out.println("Source:" + node1 + " Dest:" + node2); if (node1.equals(node2)) { firstFileMap.remove(key1); secondFileMap.remove(key1); } } catch (Exception ex) { ex.printStackTrace(); // can be ignored } } } for (String key1 : sourceKeys) { if (destKeys.contains(key1)) { identicalFiles.add(key1); sourceKeys.remove(key1); destKeys.remove(key1); } } if (outConsole == true) { } return identicalFiles; }
From source file:ch.algotrader.event.dispatch.MarketDataSubscriptionRegistry.java
public void unregister(final String strategyName, final long securityId) { Validate.notNull(strategyName, "Strategy name is null"); Set<String> strategySet = this.marketDataSubscriptionMap.get(securityId); if (strategySet != null) { strategySet.remove(strategyName); }/* ww w .ja v a 2 s .c om*/ }
From source file:ilarkesto.form.ItemFormField.java
public Collection getSelectableItems() { Set<T> result = new HashSet<T>(selectableItems); if (value != null) result.remove(value); return result; }
From source file:com.github.ikidou.handler.FormHandler.java
private void addCustomHeaders(Request request, Map<String, Object> result) { String[] normalHeaders = new String[] { "Accept-Encoding", "Connection", "Content-Length", "Content-Type", "Host", "User-Agent" }; Set<String> headers = request.headers(); for (String s : normalHeaders) { headers.remove(s); }/*from w w w . jav a2 s . c o m*/ if (!headers.isEmpty()) { Map<String, String> customHeaderMap = new HashMap<>(); for (String header : headers) { customHeaderMap.put(header, request.headers(header)); } result.put("_customHeader", customHeaderMap); } }
From source file:ch.algotrader.event.EventListenerRegistryImpl.java
@Override public <T> void unregister(final EventListener<T> listener, final Class<T> eventType) { Validate.notNull(eventType, "Event type is null"); Set<EventListener<?>> listeners = this.listenerMap.get(eventType); if (listeners != null) { listeners.remove(listener); }//w w w. j a v a 2 s . c om }
From source file:com.jivesoftware.os.amza.service.AmzaGetStress.java
private static void get(org.apache.http.client.HttpClient httpClient, String hostName, int port, String partitionName, int firstDocId, int count, int batchSize) throws IOException, InterruptedException { long start = System.currentTimeMillis(); for (int key = firstDocId; key < count; key++) { StringBuilder url = new StringBuilder(); url.append("http://"); url.append(hostName).append(":").append(port); url.append("/amza/get"); url.append("?partition=").append(partitionName); url.append("&key="); Set<String> expectedValues = Sets.newHashSet(); for (int b = 0; b < batchSize; b++) { if (b > 0) { url.append(','); }/*ww w . j a va 2 s . co m*/ url.append(b).append('k').append(key); expectedValues.add(b + "v" + key); } while (true) { HttpGet method = new HttpGet(url.toString()); StatusLine statusLine; try { try { HttpResponse response = httpClient.execute(method); statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == 200) { //System.out.println("Got:" + new String(method.getResponseBody())); ArrayNode node = mapper.readValue(EntityUtils.toString(response.getEntity()), ArrayNode.class); for (JsonNode value : node) { if (!value.isNull()) { expectedValues.remove(new String( BaseEncoding.base64().decode(value.textValue()), Charsets.UTF_8)); } } if (!expectedValues.isEmpty()) { System.out.println("Missing values in " + partitionName + " for key " + key + ": " + expectedValues); } break; } } catch (Exception x) { x.printStackTrace(); } Thread.sleep(1000); } finally { method.releaseConnection(); } } if (key % 100 == 0) { long elapse = System.currentTimeMillis() - start; double millisPerAdd = ((double) elapse / (double) key); System.out.println(partitionName + " millisPerGet:" + millisPerAdd + " getsPerSec:" + (1000d / millisPerAdd) + " key:" + key); } } }
From source file:edu.stanford.muse.graph.GroupsGraph.java
public Node<SimilarGroup<T>> removeGroup(SimilarGroup<T> g) { Node<SimilarGroup<T>> n = allNodes.remove(g); // update elementToNodes map for all the elements in the group for (T t : g.elements()) { Set<Node<SimilarGroup<T>>> set = elementToNodes.get(t); set.remove(n); }/*from www. j a v a2s . c o m*/ return n; }
From source file:org.jasig.portlet.announcements.controller.AdminRoleSetController.java
@RequestMapping(params = "action=deleteUser") public void processDeleteUser(ActionResponse response, @RequestParam("topicId") Long topicId, @RequestParam("groupKey") String groupKey, @RequestParam("userKey") String userKey) throws PortletException { Topic topic = announcementService.getTopic(topicId); Set<String> updateGroup = topic.getGroup(groupKey); updateGroup.remove(userKey); announcementService.addOrSaveTopic(topic); response.setRenderParameter("topicId", topicId.toString()); response.setRenderParameter("groupKey", groupKey); response.setRenderParameter("action", "addMembers"); }