List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:com.opengamma.id.ExternalIdBundle.java
/** * Returns a new bundle with the specified identifier removed. This instance is immutable and unaffected by this method call. * // www. j a v a 2 s . c om * @param externalId the identifier to remove from the returned bundle, not null * @return the new bundle, not null */ public ExternalIdBundle withoutExternalId(final ExternalId externalId) { ArgumentChecker.notNull(externalId, "externalId"); final Set<ExternalId> ids = new HashSet<ExternalId>(_externalIds); if (ids.remove(externalId) == false) { return this; } return create(ids); }
From source file:com.uberspot.storageutils.StorageUtils.java
/** Removes a preference in the storage from a given StringSet * @param valueName the name of the preference * @param value the value of the preference * @return true if it was saved successfully, false otherwise *///from www . j a va 2 s .co m public boolean removePreferenceFromSet(String valueName, String value) { Set<String> currentSet = getPreferenceSet(valueName, new HashSet<String>()); currentSet.remove(value); return savePreferenceSet(valueName, currentSet); }
From source file:com.google.code.ssm.test.svc.AppUserServiceImpl.java
@Override public void enableAppForUser(final int userId, final int applicationId, final boolean favourite) { AppUserPK pk = new AppUserPK(userId, applicationId); AppUser appUser = getApplicationUserFromDB(pk); if (appUser == null) { appUser = new AppUser(pk); }//from ww w. j a va2s . com appUser.setEnabled(true); if (appUser.getVersion() != 0) { getDao().update(appUser); } else { getDao().create(appUser); } Set<Integer> appsIdsSet = new HashSet<Integer>(getDao().getAppIdList(userId, true)); if (appsIdsSet.add(applicationId)) { getDao().updateListInCache(userId, true, new ArrayList<Integer>(appsIdsSet)); } appsIdsSet = new HashSet<Integer>(getDao().getAppIdList(userId, false)); if (appsIdsSet.remove(applicationId)) { getDao().updateListInCache(userId, false, new ArrayList<Integer>(appsIdsSet)); } }
From source file:net.sf.taverna.t2.activities.soaplab.SoaplabActivityTest.java
@Ignore("Integration test") @Test/*from ww w. ja va 2s.c o m*/ public void testConfigureSoaplabActivityConfigurationBean() throws Exception { Set<String> expectedOutputs = new HashSet<String>(); expectedOutputs.add("report"); expectedOutputs.add("outfile"); activity.configure(configurationBean); Set<ActivityOutputPort> ports = activity.getOutputPorts(); assertEquals(expectedOutputs.size(), ports.size()); for (ActivityOutputPort outputPort : ports) { assertTrue("Wrong output : " + outputPort.getName(), expectedOutputs.remove(outputPort.getName())); } }
From source file:com.espertech.esper.epl.join.table.PropertySortedEventTable.java
private void remove(EventBean theEvent) { Object key = getIndexedValue(theEvent); if (key == null) { nullKeyedValues.remove(theEvent); return;//from w w w.j av a 2s . com } key = coerce(key); Set<EventBean> events = propertyIndex.get(key); if (events == null) { return; } if (!events.remove(theEvent)) { // Not an error, its possible that an old-data event is artificial (such as for statistics) and // thus did not correspond to a new-data event raised earlier. return; } if (events.isEmpty()) { propertyIndex.remove(key); } }
From source file:gov.nih.nci.caarray.domain.file.CaArrayFileSet.java
/** * @return true if the status of all the files is one of the given statuses *//*from w ww . j a va 2s . com*/ @SuppressWarnings("PMD.UnusedPrivateMethod") private boolean allStatusesEqual(FileStatus... statuses) { final Set<FileStatus> fileSetStatuses = new HashSet<FileStatus>(); for (final CaArrayFile file : this.files) { fileSetStatuses.add(file.getFileStatus()); } for (final FileStatus status : statuses) { fileSetStatuses.remove(status); } return fileSetStatuses.isEmpty(); }
From source file:org.tonguetied.usermanagement.User.java
/** * Convenience method to remove a {@link UserRight} from this User. If the * UserRight does not exist then no action is taken. * // w ww. ja v a 2 s . c om * @param userRight the authorized permission to remove * @throws IllegalArgumentException if the <tt>userRight</tt> is * <tt>null</tt> or the <tt>permission</tt> is <tt>null</tt> */ public void removeUserRight(UserRight userRight) { if (userRight == null || userRight.getPermission() == null) { throw new IllegalArgumentException("userRight cannot be null"); } this.userRights.remove(userRight); final GrantedAuthority authority = new GrantedAuthorityImpl(userRight.getPermission().name()); Set<GrantedAuthority> authorities = getAuthoritiesAsSet(); authorities.remove(authority); this.setAuthorities(authorities.toArray(new GrantedAuthority[authorities.size()])); }
From source file:eu.stratosphere.nephele.services.memorymanager.spi.DefaultMemoryManager.java
@Override public void release(MemorySegment segment) { // check if segment is null or has already been freed if (segment == null || segment.isFreed() || !(segment instanceof DefaultMemorySegment)) { return;/* ww w.ja v a 2 s. c o m*/ } final DefaultMemorySegment defSeg = (DefaultMemorySegment) segment; final AbstractInvokable owner = defSeg.owner; // -------------------- BEGIN CRITICAL SECTION ------------------- synchronized (this.lock) { if (this.isShutDown) { throw new IllegalStateException("Memory manager has been shut down."); } // remove the reference in the map for the owner try { Set<DefaultMemorySegment> segsForOwner = this.allocatedSegments.get(owner); if (segsForOwner != null) { segsForOwner.remove(defSeg); if (segsForOwner.isEmpty()) { this.allocatedSegments.remove(owner); } } } catch (Throwable t) { LOG.error("Error removing book-keeping reference to allocated memory segment.", t); } finally { // release the memory in any case byte[] buffer = defSeg.destroy(); this.freeSegments.add(buffer); } } // -------------------- END CRITICAL SECTION ------------------- }
From source file:hu.netmind.beankeeper.cache.impl.MinimalResultsCache.java
/** * Remove an entry from cache./*w w w .j a v a 2 s .c o m*/ */ private void removeEntry(CacheEntry entry) { synchronized (cacheMutex) { entriesByExpiration.remove(entry); entriesByRepresentation.remove(entry.representation); Iterator tableIterator = entry.tables.iterator(); while (tableIterator.hasNext()) { String tableName = (String) tableIterator.next(); Set tableEntries = (Set) entriesByTables.get(tableName); // This shouldn't be null tableEntries.remove(entry); if (tableEntries.size() == 0) entriesByTables.remove(tableName); } // Remove from management bean synchronized (cache) { cache.setResultCount(cache.getResultCount() - 1); cache.setObjectCount(cache.getObjectCount() - entry.result.getResult().size()); } } }
From source file:scott.barleyrs.rest.EntityResultMessageBodyWriter.java
private JsonNode toJson(ObjectMapper mapper, Entity entity, Set<Entity> started) { if (!started.add(entity)) { return null; }/*from w ww. j av a 2 s. co m*/ try { ObjectNode jsonEntity = mapper.createObjectNode(); for (Node node : entity.getChildren(Node.class)) { putNode(mapper, jsonEntity, node, started); } return jsonEntity; } finally { started.remove(entity); } }