List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:jp.ac.tokushima_u.is.ll.common.orm.hibernate.HibernateWebUtils.java
/** * ?ID?,???.//from www.ja va2 s . co m * * ??????id,??????id?????. * ???id??,??id??. * ?ID, ??cascade-save-or-update. * * @param srcObjects ??,. * @param checkedIds ?,ID. * @param clazz ? * @param idName ?? */ public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds, final Class<T> clazz, final String idName) { //? Assert.notNull(srcObjects, "scrObjects?"); Assert.hasText(idName, "idName?"); Assert.notNull(clazz, "clazz?"); //?,???. if (checkedIds == null) { srcObjects.clear(); return; } //????,id?ID?,. //?,???id,?id???ID. Iterator<T> srcIterator = srcObjects.iterator(); try { while (srcIterator.hasNext()) { T element = srcIterator.next(); Object id; id = PropertyUtils.getProperty(element, idName); if (!checkedIds.contains(id)) { srcIterator.remove(); } else { checkedIds.remove(id); } } //ID??id????,,id??. for (ID id : checkedIds) { T obj = clazz.newInstance(); PropertyUtils.setProperty(obj, idName, id); srcObjects.add(obj); } } catch (Exception e) { throw ReflectionUtils.convertReflectionExceptionToUnchecked(e); } }
From source file:org.jactr.io.compiler.DefaultCompiler.java
public void removeCompiler(IUnitCompiler compiler) { Collection<Integer> relevantTypes = compiler.getRelevantTypes(); for (Integer i : relevantTypes) { Collection<IUnitCompiler> compilers = _unitCompilerMap.get(i); if (compilers != null) compilers.remove(compiler); }/*ww w . ja va 2 s . c o m*/ }
From source file:com.xyz.util.WebDataUtil.java
/** * ?ID?,???./*from w w w. j av a 2s. co m*/ * * ??????id,??????id?????. * ???id?ID?,?ID?id??. * * @param srcObjects ?? * @param checkedIds ID? * @param clazz ? * @param idName ?? */ public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds, final Class<T> clazz, final String idName) { //? Assert.notNull(srcObjects, "scrObjects?"); Assert.hasText(idName, "idName?"); Assert.notNull(clazz, "clazz?"); //ID?,???. if (checkedIds == null) { srcObjects.clear(); return; } //????,id?ID?,. //?,ID???id,ID?id???ID. Iterator<T> srcIterator = srcObjects.iterator(); try { while (srcIterator.hasNext()) { T element = srcIterator.next(); Object id; id = PropertyUtils.getProperty(element, idName); if (!checkedIds.contains(id)) { srcIterator.remove(); } else { checkedIds.remove(id); } } //ID??id????,,id??. for (ID id : checkedIds) { T obj = clazz.newInstance(); PropertyUtils.setProperty(obj, idName, id); srcObjects.add(obj); } } catch (Exception e) { throw ReflectionUtil.convertToUncheckedException(e); } }
From source file:org.eclipse.flux.client.impl.AbstractMessageConnector.java
public void removeMessageHandler(IMessageHandler messageHandler) { Collection<IMessageHandler> handlers = this.messageHandlers.get(messageHandler.getMessageType()); if (handlers != null) { handlers.remove(messageHandler); }/* w ww . j a v a 2 s. c o m*/ }
From source file:org.sonar.core.technicaldebt.TechnicalDebtManager.java
private Collection<String> getContributingPluginListWithoutSqale() { Collection<String> pluginList = newArrayList(languageModelFinder.getContributingPluginList()); pluginList.remove(TechnicalDebtModelRepository.DEFAULT_MODEL); return pluginList; }
From source file:com.afeng.common.dao.orm.HibernateWebUtils.java
/** * ?ID?,???.// w w w . ja v a 2 s . c om * <p/> * ??????id,??????id?????. * ???id??,??id??. * ?ID, ??cascade-save-or-update. * * @param srcObjects ??,. * @param checkedIds ?,ID. * @param clazz ? * @param idName ?? */ public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds, final Class<T> clazz, final String idName) { //? Assert.notNull(srcObjects, "scrObjects?"); Assert.hasText(idName, "idName?"); Assert.notNull(clazz, "clazz?"); //?,???. if (checkedIds == null) { srcObjects.clear(); return; } //????,id?ID?,. //?,???id,?id???id. Iterator<T> srcIterator = srcObjects.iterator(); try { while (srcIterator.hasNext()) { T element = srcIterator.next(); Object id; id = PropertyUtils.getProperty(element, idName); if (!checkedIds.contains(id)) { srcIterator.remove(); } else { checkedIds.remove(id); } } //ID??id????,,id??. for (ID id : checkedIds) { T obj = clazz.newInstance(); PropertyUtils.setProperty(obj, idName, id); srcObjects.add(obj); } } catch (Exception e) { throw ReflectionUtils.convertReflectionExceptionToUnchecked(e); } }
From source file:com.adito.activedirectory.GroupContainer.java
synchronized void buildHierarchy(String roleDn) { roleDn = roleDn.toLowerCase();//from w w w. j a v a 2 s .c o m ActiveDirectoryGroup role = (ActiveDirectoryGroup) dnToRoleCache.retrieve(roleDn); if (role != null) { Map<String, ActiveDirectoryGroup> parents = new HashMap<String, ActiveDirectoryGroup>(); addParents(roleDn, parents); Collection<ActiveDirectoryGroup> values = new TreeSet<ActiveDirectoryGroup>(parents.values()); values.remove(role); // groups can be recursive so it might contain itself ActiveDirectoryGroup[] toArray = values.toArray(new ActiveDirectoryGroup[parents.size()]); role.setParents(toArray); } }
From source file:com.nzion.util.UtilMisc.java
public static <T> Set<T> collectionToSet(Collection<T> c) { if (c == null) return null; Set<T> theSet = null;//from ww w . ja v a 2 s . c o m if (c instanceof Set) { theSet = (Set<T>) c; } else { theSet = new HashSet<T>(); c.remove(null); theSet.addAll(c); } return theSet; }
From source file:uk.co.modularaudio.util.audio.mad.graph.GraphLinkMap.java
public void removeMadInstance(final MadInstance<?, ?> instance) { final Collection<MadLink> consumerLinks = consumerInstanceLinks.get(instance); if (consumerLinks != null) { final Collection<MadLink> toRemove = new ArrayList<MadLink>(consumerLinks); for (final MadLink link : toRemove) { instanceLinks.remove(link);// w w w . ja v a 2 s . c om final MadChannelInstance pci = link.getProducerChannelInstance(); final MadInstance<?, ?> mi = pci.instance; final Collection<MadLink> mls = producerInstanceLinks.get(mi); mls.remove(link); } consumerInstanceLinks.remove(instance); } final Collection<MadLink> producerLinks = producerInstanceLinks.get(instance); if (producerLinks != null) { final Collection<MadLink> toRemove = new ArrayList<MadLink>(producerLinks); for (final MadLink link : toRemove) { instanceLinks.remove(link); final MadChannelInstance cci = link.getConsumerChannelInstance(); final MadInstance<?, ?> mi = cci.instance; final Collection<MadLink> mls = consumerInstanceLinks.get(mi); mls.remove(link); } producerInstanceLinks.remove(instance); } }
From source file:org.sonar.server.rule.DeprecatedRulesDefinition.java
private Collection<String> getContributingPluginListWithoutSqale() { Collection<String> pluginList = newArrayList(languageModelFinder.getContributingPluginList()); pluginList.remove(DebtModelPluginRepository.DEFAULT_MODEL); return pluginList; }