List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:org.xwiki.watchlist.internal.DefaultWatchListStore.java
@Override public boolean removeWatchedElement(String user, String watchedElement, WatchedElementType type) throws XWikiException { XWikiContext context = contextProvider.get(); String elementToRemove = watchedElement; if (!WatchedElementType.WIKI.equals(type) && !watchedElement.contains(WIKI_SPACE_SEP)) { elementToRemove = context.getWikiId() + WIKI_SPACE_SEP + watchedElement; }/*from www. j a v a2s . c o m*/ if (!this.isWatched(elementToRemove, user, type)) { return false; } Collection<String> watchedElements = getWatchedElements(user, type); watchedElements.remove(elementToRemove); this.setWatchListElementsProperty(user, type, watchedElements); return true; }
From source file:ubic.gemma.analysis.sequence.SequenceManipulation.java
/** * Convert a CompositeSequence's immobilizedCharacteristics into a single sequence, using a simple merge-join * strategy.// w w w . j a v a 2 s. c o m * * @param sequences * @return BioSequence. Not all fields are filled in and must be set by the caller. */ public static BioSequence collapse(Collection<Reporter> sequences) { Collection<Reporter> copyOfSequences = copyReporters(sequences); BioSequence collapsed = BioSequence.Factory.newInstance(); collapsed.setSequence(""); if (log.isDebugEnabled()) log.debug("Collapsing " + sequences.size() + " sequences"); while (!copyOfSequences.isEmpty()) { Reporter next = findLeftMostProbe(copyOfSequences); int ol = SequenceManipulation.rightHandOverlap(collapsed, next.getImmobilizedCharacteristic()); String nextSeqStr = next.getImmobilizedCharacteristic().getSequence(); collapsed.setSequence(collapsed.getSequence() + nextSeqStr.substring(ol)); if (log.isDebugEnabled()) { log.debug( "New Seq to add: " + nextSeqStr + " Overlap=" + ol + " Result=" + collapsed.getSequence()); } copyOfSequences.remove(next); } collapsed.setIsCircular(false); collapsed.setIsApproximateLength(false); collapsed.setLength(new Long(collapsed.getSequence().length())); collapsed.setDescription("Collapsed from " + sequences.size() + " reporter sequences"); return collapsed; }
From source file:org.fracturedatlas.athena.apa.BaseApaAdapterTest.java
/** * Compares two lists for equality ignoring order. * @param col1//from w ww . j a v a 2 s. c o m * @param col2 */ public void doCollectionsContainSameElements(Collection col1, Collection col2) { if (col1 == null) { assertNull(col2); } else if (col2 == null) { fail("One list is null and the other is not"); } assertEquals(col1.size(), col2.size()); for (Object o : col2) { col1.remove(o); } assertEquals(0, col1.size()); }
From source file:org.jboss.tools.openshift.internal.ui.models.ObservableResourceCache.java
private void flushCacheBuildConfigByOutput(IBuildConfig config) { String imageRef = imageRef(config); if (imageRefToBuildConfigs.containsKey(imageRef)) { synchronized (imageRefToBuildConfigs) { Collection<IBuildConfig> configs = imageRefToBuildConfigs.get(imageRef); if (configs != null) { configs.remove(config); if (configs.isEmpty()) { imageRefToBuildConfigs.remove(imageRef); }/*from w w w . j a v a2s . co m*/ } } } }
From source file:org.codehaus.mojo.license.api.DefaultThirdPartyHelper.java
/** * {@inheritDoc}/*from w ww .ja va 2 s. c o m*/ */ @SuppressWarnings("unchecked") // project.getArtifacts() public SortedProperties createUnsafeMapping(LicenseMap licenseMap, File missingFile, boolean useRepositoryMissingFiles, SortedSet<MavenProject> unsafeDependencies, SortedMap<String, MavenProject> projectDependencies) throws ProjectBuildingException, IOException, ThirdPartyToolException { SortedProperties unsafeMappings = loadUnsafeMapping(licenseMap, missingFile, projectDependencies); if (CollectionUtils.isNotEmpty(unsafeDependencies)) { // there is some unresolved license if (useRepositoryMissingFiles) { // try to load missing third party files from dependencies Collection<MavenProject> projects = new ArrayList<MavenProject>(projectDependencies.values()); projects.remove(project); projects.removeAll(unsafeDependencies); SortedProperties resolvedUnsafeMapping = loadThirdPartyDescriptorForUnsafeMapping( project.getArtifacts(), unsafeDependencies, projects, licenseMap); // push back resolved unsafe mappings unsafeMappings.putAll(resolvedUnsafeMapping); } } return unsafeMappings; }
From source file:org.codehaus.griffon.plugins.DefaultGriffonPlugin.java
private void addExcludeRuleInternal(Map map, Object o) { Collection excludes = (Collection) map.get(EXCLUDES); if (excludes == null) { excludes = new ArrayList(); map.put(EXCLUDES, excludes);//from w ww . j a v a2 s .co m } Collection includes = (Collection) map.get(INCLUDES); if (includes != null) includes.remove(o); excludes.add(o); }
From source file:org.jboss.tools.openshift.internal.ui.models.ObservableResourceCache.java
private void flushCacheDeploymentConfigByImageChangeTrigger(IDeploymentConfig dc) { Collection<IDeploymentTrigger> triggers = dc.getTriggers().stream() .filter(t -> DeploymentTriggerType.IMAGE_CHANGE.equals(t.getType())).collect(Collectors.toList()); for (IDeploymentTrigger trigger : triggers) { String imageRef = imageRef((IDeploymentImageChangeTrigger) trigger); synchronized (imageRefToDeployConfigs) { if (imageRefToDeployConfigs.containsKey(imageRef)) { Collection<IDeploymentConfig> configs = imageRefToDeployConfigs.get(imageRef); if (configs != null) { configs.remove(dc); if (configs.isEmpty()) { imageRefToDeployConfigs.remove(imageRef); }/*from w w w . j a v a 2s . com*/ } } } } }
From source file:ubc.pavlab.aspiredb.server.util.PhenotypeUtil.java
/** * Builds a list of RestrictionExpressions by comparing the HumanPhenotypeOntology against the Phenotypes in the * database and assign Phenotype values as appropriate. * // www . j a v a 2 s . c om * @param phenotype * @param activeProjectIds * @return */ private Collection<RestrictionExpression> expandPhenotypeRestriction(PhenotypeRestriction phenotype, Collection<Long> activeProjectIds) { HumanPhenotypeOntologyService humanPhenotypeOntology = os.getHumanPhenotypeOntologyService(); Set<RestrictionExpression> expandedRestrictions = new HashSet<RestrictionExpression>(); expandedRestrictions.add(phenotype); if (!humanPhenotypeOntology.isOntologyLoaded()) { loadOntology(); } resolveUri(phenotype); if (!phenotype.isOntologyTerm()) { log.warn("\"" + phenotype.getName() + "\" is not an ontology term"); return expandedRestrictions; } OntologyTerm term = humanPhenotypeOntology.getTerm(HUMAN_PHENOTYPE_URI_PREFIX + phenotype.getUri()); if (term == null) { log.error(HUMAN_PHENOTYPE_URI_PREFIX + phenotype.getUri() + " not found in Ontology"); return expandedRestrictions; } Collection<String> existingTerms = phenotypeDao.getExistingNames(activeProjectIds); existingTerms.remove(phenotype.getName()); if (phenotype.isAbsent()) { expandedRestrictions.remove(phenotype); // conjunction: make sure all the child are Absent Conjunction conj = new Conjunction(); Conjunction conjDescendants = new Conjunction(); Set<PhenotypeRestriction> descendantRestrictions = new HashSet<PhenotypeRestriction>(); createRestrictionsForDescendants(VALUE_ABSENT, term, descendantRestrictions, existingTerms); /* * log.debug( "descendant (" + descendantRestrictions.size() + "): " ); for ( PhenotypeRestriction r : * descendantRestrictions ) { log.debug( "; " + r.getName() + "=" + r.getValue() ); } log.debug( "" ); */ conjDescendants.addAll(descendantRestrictions); conj.add(phenotype); conj.add(conjDescendants); expandedRestrictions.add(conj); } else if (phenotype.isPresent()) { expandedRestrictions.remove(phenotype); // disjunction: count if at least one child penotype is Present Disjunction disj = new Disjunction(); Set<PhenotypeRestriction> descendantRestrictions = new HashSet<PhenotypeRestriction>(); createRestrictionsForDescendants(VALUE_PRESENT, term, descendantRestrictions, existingTerms); descendantRestrictions.add(phenotype); disj.addAll(descendantRestrictions); expandedRestrictions.add(disj); } return expandedRestrictions; }
From source file:de.hybris.platform.b2bacceleratorservices.company.impl.DefaultB2BCommerceUnitService.java
@Override public void removeAddressEntry(final String unitUid, final String addressId) { final B2BUnitModel unit = this.getUnitForUid(unitUid); validateParameterNotNullStandardMessage("B2BUnit", unit); final Collection<AddressModel> addresses = new ArrayList<AddressModel>(unit.getAddresses()); for (final AddressModel addressModel : addresses) { if (addressModel.getPk().getLongValueAsString().equals(addressId)) { addresses.remove(addressModel); unit.setAddresses(addresses); getModelService().remove(addressModel); break; }// ww w .j a v a 2 s. c o m } }
From source file:com.create.security.oauth2.provider.token.SpringCacheTokenStoreImpl.java
@Override public void removeAccessToken(final String tokenValue) { final OAuth2AccessToken removed = tokenRepository.removeAccessToken(tokenValue); tokenRepository.removeAccessTokenToRefreshToken(tokenValue); final OAuth2Authentication authentication = tokenRepository.removeAuthentication(tokenValue); if (authentication != null) { tokenRepository.removeAuthenticationToAccessToken(authentication); Collection<OAuth2AccessToken> tokens; String clientId = authentication.getOAuth2Request().getClientId(); tokens = tokenRepository.findTokensByClientIdAndUserName(clientId, authentication.getName()); if (tokens != null) { tokens.remove(removed); }/* www . j a v a2 s . co m*/ tokens = tokenRepository.findTokensByClientId(clientId); if (tokens != null) { tokens.remove(removed); } tokenRepository.removeAuthenticationToAccessToken(authentication); } }