List of usage examples for com.google.common.collect Sets difference
public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2)
From source file:org.apache.james.mailbox.model.MessageMoves.java
public Set<MailboxId> addedMailboxIds() { return Sets.difference(targetMailboxIds, previousMailboxIds); }
From source file:org.apache.rya.indexing.external.matching.FlattenedOptional.java
public FlattenedOptional(LeftJoin node) { rightArgs = getJoinArgs(node.getRightArg(), new HashSet<TupleExpr>()); boundVars = setWithOutConstants(Sets.intersection(node.getLeftArg().getAssuredBindingNames(), node.getRightArg().getBindingNames())); unboundVars = setWithOutConstants(Sets.difference(node.getRightArg().getBindingNames(), boundVars)); condition = node.getCondition();//from w w w .j a va 2 s . c om rightArg = node.getRightArg(); getVarCounts(node); assuredBindingNames = new HashSet<>(leftArgVarCounts.keySet()); bindingNames = new HashSet<>(Sets.union(assuredBindingNames, unboundVars)); }
From source file:org.eclipse.sw360.moderation.db.ModerationRequestGenerator.java
private Set<String> getDeletedStrings(Set<String> actualStrings, Set<String> updateStrings) { return Sets.difference(nullToEmptySet(actualStrings), nullToEmptySet(updateStrings)); }
From source file:org.caleydo.view.relationshipexplorer.ui.collection.idprovider.ElementIDProviders.java
/** * Gets a Provider that returns the difference of all elements given by the specified providers. Note that this * difference is cached once and will not be recalculated when calling {@link IElementIDProvider#getElementIDs()}. * * @param providers/*from w w w .jav a2s. c o m*/ * @return */ public static IElementIDProvider differenceOf(IElementIDProvider... providers) { Set<Object> elementIDs = new HashSet<>(); for (IElementIDProvider provider : providers) { elementIDs = Sets.difference(elementIDs, provider.getElementIDs()); } return new SimpleElementIDProvider(elementIDs); }
From source file:com.facebook.buck.core.build.engine.impl.BuildRulePipelinesRunner.java
/** Gives the factory a way to construct a {@link RunnableWithFuture} to build the given rule. */ public <T extends RulePipelineState> void addRule(SupportsPipelining<T> rule, Function<T, RunnableWithFuture<Optional<BuildResult>>> ruleStepRunnerFactory) { BuildRulePipelineStage<T> pipelineStage = getPipelineStage(rule); SupportsPipelining<T> previousRuleInPipeline = rule.getPreviousRuleInPipeline(); if (previousRuleInPipeline != null) { Preconditions.checkState(//w w w. j a va2 s . c om previousRuleInPipeline.getPipelineStateFactory() == rule.getPipelineStateFactory(), "To help ensure that rules have pipeline-compatible rule keys, all rules in a pipeline must share a PipelineStateFactory instance."); SortedSet<BuildRule> currentDeps = rule.getBuildDeps(); SortedSet<BuildRule> previousDeps = previousRuleInPipeline.getBuildDeps(); Preconditions.checkState(currentDeps.contains(previousRuleInPipeline), "Each rule in a pipeline must depend on the previous rule in the pipeline."); SetView<BuildRule> extraDeps = Sets.difference(currentDeps, Sets.union(previousDeps, Collections.singleton(previousRuleInPipeline))); Preconditions.checkState(extraDeps.isEmpty(), "Each rule in a pipeline cannot depend on rules which are not also dependencies of the previous rule in the pipeline. " + "This ensures that each rule in the pipeline is ready to build as soon as the previous one completes. " + "%s has extra deps <%s>.", rule, Joiner.on(", ").join(extraDeps)); getPipelineStage(previousRuleInPipeline).setNextStage(pipelineStage); } pipelineStage.setRuleStepRunnerFactory(ruleStepRunnerFactory); }
From source file:pgentity.services.FriendServices.java
public void reloadFriendList(FriendList frList, SNServices sns, UserTempData uTempData, long now) throws ZingMeApiException, IOException { Set<String> zmFriendIDs = this.getPGFriends(sns); Set<String> npcs = new HashSet(NPCList.getNPCList(frList.getUid()).getAll()); Set<String> curFriendIDs = Sets.difference(frList.getAll(), npcs); Set<String> unfriendIDs = Sets.difference(curFriendIDs, zmFriendIDs); if (unfriendIDs.size() > 0) { for (String unFid : unfriendIDs) { FriendList frFriendList = FriendList.getFriendList(unFid); frFriendList.remove(frList.getUid()); }/* w ww. ja v a 2s . c o m*/ String[] unfriendIDArr = unfriendIDs.toArray(new String[unfriendIDs.size()]); frList.remove(unfriendIDArr); } Set<String> newFriendIDs = new HashSet(Sets.difference(zmFriendIDs, curFriendIDs)); for (String fid : newFriendIDs) { FriendList frFriendList = FriendList.getFriendList(fid); frFriendList.add(frList.getUid()); } String adminUID = PGConfig.inst().temp().Admin_UID(); if (!adminUID.equals(uTempData.getUid()) && User.isExist(adminUID)) { newFriendIDs.add(PGConfig.inst().temp().Admin_UID()); } if (newFriendIDs.size() > 0) { String[] newFriendIDArr = newFriendIDs.toArray(new String[newFriendIDs.size()]); frList.add(newFriendIDArr); } uTempData.setData(PGMacro.LAST_TIME_SYNC_FRIEND_LIST, now); }
From source file:org.eclipse.sirius.ext.base.collect.GSetIntersection.java
/** * {@inheritDoc}//from ww w .jav a 2 s .co m */ @Override public Iterable<E> getRemovedElements() { return Iterables.concat(extraElementsToDelete, Sets.difference(oldElements.values(), newElements)); }
From source file:org.apache.maven.plugins.shade.filter.ClassDependencies.java
final Set<String> buildAllUnusedClasses() { TransitiveDependenciesCollector collecter = new TransitiveDependenciesCollector(); collecter.addAll(included);//from ww w . j a va 2 s. c om collectUsedServiceProviders(collecter); return Sets.difference(classes, collecter.all); }
From source file:io.crate.analyze.repositories.RepositoryParamValidator.java
public Settings convertAndValidate(String type, Optional<GenericProperties> genericProperties, ParameterContext parameterContext) { TypeSettings typeSettings = this.typeSettings.get(type); if (typeSettings == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "Invalid repository type \"%s\"", type)); }/* w w w . jav a 2 s .c o m*/ Map<String, SettingsApplier> allSettings = typeSettings.all(); // create string settings applier for all dynamic settings Optional<GenericProperties> dynamicProperties = typeSettings.dynamicProperties(genericProperties); if (dynamicProperties.isPresent()) { // allSettings are immutable by default, copy map allSettings = Maps.newHashMap(allSettings); for (String key : dynamicProperties.get().properties().keySet()) { allSettings.put(key, new SettingsAppliers.StringSettingsApplier(new StringSetting(key, true))); } } // convert and validate all settings Settings settings = GenericPropertiesConverter .settingsFromProperties(genericProperties, parameterContext, allSettings).build(); Set<String> names = settings.getAsMap().keySet(); Sets.SetView<String> missingRequiredSettings = Sets.difference(typeSettings.required().keySet(), names); if (!missingRequiredSettings.isEmpty()) { throw new IllegalArgumentException(String.format(Locale.ENGLISH, "The following required parameters are missing to create a repository of type \"%s\": [%s]", type, Joiner.on(", ").join(missingRequiredSettings))); } return settings; }
From source file:org.apache.james.mailbox.model.MessageMoves.java
public Set<MailboxId> removedMailboxIds() { return Sets.difference(previousMailboxIds, targetMailboxIds); }