private void scheduleRecentlyAddedMaterialsForUpdate() { Collection<Material> materialsBeforeConfigChange = dependencyMaterials.values(); this.dependencyMaterials = dependencyMaterials(); Collection<Material> materialsAfterConfigChange = dependencyMaterials.values(); Collection newMaterials = CollectionUtils.subtract(materialsAfterConfigChange, materialsBeforeConfigChange); for (Object material : newMaterials) { updateMaterial((Material) material); } }
/** * Returns a new {@link Collection} containing {@code <i>a</i> - <i>b</i>}. * The cardinality of each element <i>e</i> in the returned {@link Collection} * will be the cardinality of <i>e</i> in <i>a</i> minus the cardinality * of <i>e</i> in <i>b</i>, or zero, whichever is greater. * * @param a the collection to subtract from, must not be null * @param b the collection to subtract, must not be null * @param <O> the generic type that is able to represent the types contained * in both input collections. * @return a new collection with the results * @see Collection#removeAll */ public static <O> Collection<O> subtract(final Iterable<? extends O> a, final Iterable<? extends O> b) { final Predicate<O> p = TruePredicate.truePredicate(); return subtract(a, b, p); }
public boolean shouldBeIgnoredByFilterIn(MaterialConfig materialConfig) { if (materialConfig.filter().shouldNeverIgnore()) { return false; } Set<ModifiedFile> allFiles = getAllFiles(this); Set<ModifiedFile> ignoredFiles = new HashSet<>(); for (ModifiedFile file : allFiles) { appyIgnoreFilter(materialConfig, file, ignoredFiles); } LOG.debug("Checking ignore filters for {}", materialConfig); LOG.debug("Ignored files: {}", ignoredFiles); LOG.debug("Changed files: {}", CollectionUtils.subtract(allFiles, ignoredFiles)); if (materialConfig.isInvertFilter()) { // return true (ignore) if we are inverting the filter, and the ignoredFiles and allFiles are disjoint sets return Collections.disjoint(allFiles, ignoredFiles); } else { return ignoredFiles.containsAll(allFiles); } }
@SuppressWarnings("unchecked") public Collection<BookieSocketAddress> getPartialScanTargets() { return CollectionUtils.subtract(mostRecentlyReportedBookies, infoMap.keySet()); }
private AccessCertificationResponseType extractStageOutcome(Set<AccessCertificationResponseType> stageOutcomes, Long caseId, int stage) { Collection<AccessCertificationResponseType> nonNullOutcomes = CollectionUtils.subtract(stageOutcomes, singleton(NO_RESPONSE)); if (nonNullOutcomes.size() > 1) { throw new IllegalStateException("Contradictory outcomes for case " + caseId + " in stage " + stage + ": " + stageOutcomes); } else if (!nonNullOutcomes.isEmpty()) { return nonNullOutcomes.iterator().next(); } else if (!stageOutcomes.isEmpty()) { return NO_RESPONSE; } else { return null; } } }
public void updateEndPoints(List<EndPoint> newEndPoints) { Collection<EndPoint> addList = CollectionUtils.subtract(newEndPoints, endPoints); Collection<EndPoint> deleteList = CollectionUtils.subtract(endPoints, newEndPoints); for (EndPoint endPoint : addList) { addEndPoint(endPoint); } for (EndPoint endPoint : deleteList) { deleteEndPoint(endPoint); } }
public void updateEndPoints(List<EndPoint> newEndPoints) { Collection<EndPoint> addList = CollectionUtils.subtract(newEndPoints, endPoints); Collection<EndPoint> deleteList = CollectionUtils.subtract(endPoints, newEndPoints); for (EndPoint endPoint : addList) { addEndPoint(endPoint); } for (EndPoint endPoint : deleteList) { deleteEndPoint(endPoint); } }
@Override public void run(Timeout timeout) throws Exception { try { List<EndPoint> currentEndPoints = lookup(null); Collection<EndPoint> addList = CollectionUtils.subtract( currentEndPoints, lastEndPoints); Collection<EndPoint> deleteList = CollectionUtils.subtract( lastEndPoints, currentEndPoints); listener.notify(addList, deleteList); } catch (Exception ex) { // ignore exception } namingServiceTimer.newTimeout(this, updateInterval, TimeUnit.MILLISECONDS); } },
@Override public void run(Timeout timeout) throws Exception { try { List<EndPoint> currentEndPoints = lookup(null); Collection<EndPoint> addList = CollectionUtils.subtract( currentEndPoints, lastEndPoints); Collection<EndPoint> deleteList = CollectionUtils.subtract( lastEndPoints, currentEndPoints); listener.notify(addList, deleteList); } catch (Exception ex) { // ignore exception } namingServiceTimer.newTimeout(this, updateInterval, TimeUnit.MILLISECONDS); } },
public void setScope(ScopedIF scoped, Collection<Topic> scope) { if (scope != null) { Collection<TopicIF> newScope = new HashSet<>(scope.size()); for (Topic t : scope) { TopicIF resolved = topic.resolve(scoped.getTopicMap(), t); newScope.add(resolved); scoped.addTheme(resolved); } for (TopicIF remove : CollectionUtils.subtract(scoped.getScope(), newScope)) { scoped.removeTheme(remove); } } }
private void consistBatch(String interfaze, List<ApplicationEntity> remoteList) throws Exception { List<ApplicationEntity> localList = cacheContainer.getConnectionCacheEntity().getApplicationEntityList(interfaze); if (!CollectionUtils.isEqualCollection(localList, remoteList)) { List<ApplicationEntity> intersectedList = (List<ApplicationEntity>) CollectionUtils.intersection(localList, remoteList); List<ApplicationEntity> onlineList = (List<ApplicationEntity>) CollectionUtils.subtract(remoteList, intersectedList); List<ApplicationEntity> offlineList = (List<ApplicationEntity>) CollectionUtils.subtract(localList, intersectedList); consistBatchClient(interfaze, onlineList, true); consistBatchClient(interfaze, offlineList, false); } }
public void setTypes(TopicIF object, Topic pojo) { if (pojo.getTypes() != null) { Collection<TopicIF> newTypes = new HashSet<>(pojo.getTypes().size()); for (Topic t : pojo.getTypes()) { TopicIF resolved = resolve(object.getTopicMap(), t); newTypes.add(resolved); } for (TopicIF remove : CollectionUtils.subtract(object.getTypes(), newTypes)) { object.removeType(remove); } for (TopicIF add : newTypes) { object.addType(add); } } }
@SuppressWarnings("unchecked") @Override public Set<DefinitionMetadata> unregisterAndRegister(Collection<DefinitionMetadata> metaDataToUnregister, Collection<DefinitionProvider<AppDescriptor>> providersToRegister) { Collection<DefinitionMetadata> metadataBefore = getRegistryMap().keySet(); Collection<DefinitionProvider<AppDescriptor>> providersBefore = getRegistryMap().values(); Set<DefinitionMetadata> registeredMetaData = super.unregisterAndRegister(metaDataToUnregister, providersToRegister); Collection<DefinitionMetadata> metadataAfter = getRegistryMap().keySet(); Collection<DefinitionMetadata> added = CollectionUtils.subtract(metadataAfter, metadataBefore); Collection<DefinitionMetadata> removed = CollectionUtils.subtract(metadataBefore, metadataAfter); Collection<DefinitionMetadata> kept = CollectionUtils.subtract(metadataBefore, removed); Collection<DefinitionMetadata> changed = getAppsThatHaveChanged(kept, providersBefore, providersToRegister); sendEvent(AppRegistryEventType.REGISTERED, added); sendEvent(AppRegistryEventType.UNREGISTERED, removed); sendEvent(AppRegistryEventType.REREGISTERED, changed); return registeredMetaData; }
public DocumentationMetadataBuilder(SType<?> rootStype) { initTypeByNameCache(rootStype); tableRoots = identifyTablesRoots(rootStype); LinkedHashSet<SType<?>> tableRootsSTypes = tableRoots.stream().flatMap(d -> d.getRootSTypes().stream()).collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll); for (DocTable docTable : tableRoots) { LinkedHashSet<DocBlock> docBlocks = identifyBlocks(docTable.getRootSTypes(), tableRootsSTypes); docTable.addAllDocBlocks(docBlocks); LinkedHashSet<SType<?>> allTypesAssociatedToBlocks = gatherAllSTypesAssociatedToBlocks(docBlocks); allTypesAssociatedToBlocks.addAll(tableRootsSTypes); for (DocBlock docBlock : docBlocks) { LinkedHashSet<DocFieldMetadata> docFieldMetadata = identifyFields(rootStype, docBlock, CollectionUtils.subtract(allTypesAssociatedToBlocks, docBlock.getBlockTypes())); docBlock.addAllFieldsMetadata(docFieldMetadata); } } }
public DocumentationMetadataBuilder(SType<?> rootStype) { initTypeByNameCache(rootStype); tableRoots = identifyTablesRoots(rootStype); LinkedHashSet<SType<?>> tableRootsSTypes = tableRoots.stream().flatMap(d -> d.getRootSTypes().stream()).collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll); for (DocTable docTable : tableRoots) { LinkedHashSet<DocBlock> docBlocks = identifyBlocks(docTable.getRootSTypes(), tableRootsSTypes); docTable.addAllDocBlocks(docBlocks); LinkedHashSet<SType<?>> allTypesAssociatedToBlocks = gatherAllSTypesAssociatedToBlocks(docBlocks); allTypesAssociatedToBlocks.addAll(tableRootsSTypes); for (DocBlock docBlock : docBlocks) { LinkedHashSet<DocFieldMetadata> docFieldMetadata = identifyFields(rootStype, docBlock, CollectionUtils.subtract(allTypesAssociatedToBlocks, docBlock.getBlockTypes())); docBlock.addAllFieldsMetadata(docFieldMetadata); } } }
public DocumentationMetadataBuilder(SType<?> rootStype) { initTypeByNameCache(rootStype); tableRoots = identifyTablesRoots(rootStype); LinkedHashSet<SType<?>> tableRootsSTypes = tableRoots.stream().flatMap(d -> d.getRootSTypes().stream()).collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll); for (DocTable docTable : tableRoots) { LinkedHashSet<DocBlock> docBlocks = identifyBlocks(docTable.getRootSTypes(), tableRootsSTypes); docTable.addAllDocBlocks(docBlocks); LinkedHashSet<SType<?>> allTypesAssociatedToBlocks = gatherAllSTypesAssociatedToBlocks(docBlocks); allTypesAssociatedToBlocks.addAll(tableRootsSTypes); for (DocBlock docBlock : docBlocks) { LinkedHashSet<DocFieldMetadata> docFieldMetadata = identifyFields(rootStype, docBlock, CollectionUtils.subtract(allTypesAssociatedToBlocks, docBlock.getBlockTypes())); docBlock.addAllFieldsMetadata(docFieldMetadata); } } }
public void setSubjectLocators(TopicIF object, Topic pojo) { if (pojo.getSubjectLocators() != null) { Collection<LocatorIF> toRemove = CollectionUtils.subtract(object.getSubjectLocators(), pojo.getSubjectLocators()); for (LocatorIF sl : pojo.getSubjectLocators()) { object.addSubjectLocator(sl); } for (LocatorIF sl : toRemove) { object.removeSubjectLocator(sl); } } }
public void setItemIdentifiers(TMObjectIF object, TMObject pojo) { if (pojo.getItemIdentifiers() != null) { Collection<LocatorIF> toRemove = CollectionUtils.subtract(object.getItemIdentifiers(), pojo.getItemIdentifiers()); for (LocatorIF ii : pojo.getItemIdentifiers()) { object.addItemIdentifier(ii); } for (LocatorIF ii : toRemove) { object.removeItemIdentifier(ii); } } }
public void setSubjectIdentifiers(TopicIF object, Topic pojo) { if (pojo.getSubjectIdentifiers() != null) { Collection<LocatorIF> toRemove = CollectionUtils.subtract(object.getSubjectIdentifiers(), pojo.getSubjectIdentifiers()); for (LocatorIF si : pojo.getSubjectIdentifiers()) { object.addSubjectIdentifier(si); } for (LocatorIF si : toRemove) { object.removeSubjectIdentifier(si); } } }