List of usage examples for com.google.common.collect Sets union
public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2)
From source file:org.apache.james.jmap.methods.GetMailboxesMethod.java
private Set<MailboxProperty> ensureContainsId(Set<MailboxProperty> input) { return Sets.union(input, ImmutableSet.of(MailboxProperty.ID)).immutableCopy(); }
From source file:org.dllearner.learningproblems.EvaluationCache.java
/** * Determines which examples are instances of a concept. * @param concept the concept/*from w ww .j ava2 s . co m*/ * @return A tuple of two sets, where the first element is the * set of individuals belonging to the class and the second element * is the set of individuals not belonging to the class. For all * elements, which are in neither of the sets, the cache cannot * safely determine whether they are concept instances or not. */ public SortedSetTuple<OWLIndividual> infer(OWLClassExpression concept) { if (checkForEqualConcepts) { Set<OWLIndividual> pos = cache.get(concept); Set<OWLIndividual> neg = Sets.difference(examples, pos); return new SortedSetTuple<>(pos, neg); } else { // for a negation NOT C we can only say which concepts are not in it // (those in C), but we cannot say which ones are in NOT C // for a conjunction we know that the intersection of instances // of all children belongs to the concept if (concept instanceof OWLObjectIntersectionOf) { handleMultiConjunction((OWLObjectIntersectionOf) concept); // disjunctions are similar to conjunctions but we use union here; // note that there can be instances which are neither in a concept // C nor in a concept D, but in (C OR D) } else if (concept instanceof OWLObjectUnionOf) { List<OWLClassExpression> operands = ((OWLObjectUnionOf) concept).getOperandsAsList(); Set<OWLIndividual> pos = cache.get(operands.get(0)); for (int i = 1; i < operands.size(); i++) { pos = Sets.union(pos, cache.get(operands.get(i))); } // in all other cases we cannot infer anything, so we return an // empty tuple } else { return new SortedSetTuple<>(); } } return null; }
From source file:grakn.core.graql.reasoner.query.ReasonerAtomicQuery.java
@Override public ReasonerAtomicQuery withSubstitution(ConceptMap sub) { return new ReasonerAtomicQuery(Sets.union(this.getAtoms(), AtomicFactory.answerToPredicates(sub, this)), this.tx()); }
From source file:org.jboss.hal.client.runtime.subsystem.jaxrs.RestResourceColumn.java
@Inject public RestResourceColumn(Finder finder, FinderPathFactory finderPathFactory, ColumnActionFactory columnActionFactory, Environment environment, ServerActions serverActions, DeploymentResources deploymentResources, Places places, StatementContext statementContext, Resources resources) {//ww w. ja va 2 s . com super(new FinderColumn.Builder<RestResource>(finder, Ids.REST_RESOURCE, Names.REST_RESOURCE) .columnAction(columnActionFactory.refresh(Ids.REST_RESOURCE_REFRESH)) .itemsProvider((context, callback) -> deploymentResources.readChildren(JAX_RS, REST_RESOURCE, RestResource::new, restResources -> { restResources.sort(Comparator.comparing(RestResource::getName)); callback.onSuccess(restResources); })) .itemRenderer(item -> new ItemDisplay<RestResource>() { @Override public String getId() { return Ids.restResource(item.getDeployment(), item.getSubdeployment(), item.getName()); } @Override public String getTitle() { return abbreviateFqClassName(item.getName()); } @Override public HTMLElement element() { HTMLElement element = ItemDisplay.withSubtitle(abbreviateFqClassName(item.getName()), item.getPath()); element.classList.add(breakTooltip); return element; } @Override public String getFilterData() { String resourceMethods = String.join(" ", item.getResourceMethods()); String mediaTypes = String.join(" ", Sets.union(item.getConsumes(), item.getProduces()).immutableCopy()); return String.join(" ", item.getName(), resourceMethods, mediaTypes); } @Override public String getTooltip() { return item.getName(); } }) .onPreview(item -> new RestResourcePreview(item, environment, finderPathFactory, places, serverActions, statementContext, resources)) .useFirstActionAsBreadcrumbHandler().withFilter() .filterDescription(resources.messages().restColumnFilterDescription()).showCount().pinnable()); }
From source file:org.tensorics.core.tensor.options.BroadcastMissingDimensionsStrategy.java
@Override public <V> TensorPair<V> broadcast(Tensor<V> left, Tensor<V> right, Set<Class<?>> excludedDimensions) { checkNotNull(left, "left tensor must not be null"); checkNotNull(right, "right tensor must not be null"); Set<Class<?>> dimensionalIntersection = Shapes.parentDimensionalIntersection(left.shape(), right.shape()); Set<Class<?>> notBroadcastedDimensions = Sets.union(dimensionalIntersection, excludedDimensions) .immutableCopy();//from www . ja v a 2s .c o m Shape missingLeft = dimensionStripped(right.shape(), notBroadcastedDimensions); Shape missingRight = dimensionStripped(left.shape(), notBroadcastedDimensions); return TensorPair.fromLeftRight(new BroadcastedTensorView<V>(left, missingLeft), new BroadcastedTensorView<V>(right, missingRight)); }
From source file:com.facebook.buck.tools.dxanalysis.MutabilityAnalyzer.java
public boolean isTypeImmutable(String desc) { Type type = Type.getType(desc); if (IMMUTABLE_TYPE_SORTS.contains(type.getSort())) { return true; }//ww w. j a va 2s . com if (type.getSort() != Type.OBJECT) { return false; } if (Sets.union(EXTERNAL_IMMUTABLE_CLASSES, immutableClasses).contains(type.getInternalName())) { return true; } return false; }
From source file:org.apache.james.jmap.model.MessageProperties.java
private MessageProperties ensureContains(ImmutableSet<MessageProperty> mandatoryFields) { return usingProperties(Sets.union(buildOutputMessageProperties(), mandatoryFields)); }
From source file:dagger.internal.codegen.Binding.java
/** * The set of {@link DependencyRequest dependencies} required to satisfy this binding. This is the * union of {@link #explicitDependencies()} and {@link #implicitDependencies()}. This returns an * unmodifiable set.//from ww w .ja v a 2s . c om */ final Set<DependencyRequest> dependencies() { Set<DependencyRequest> implicitDependencies = implicitDependencies(); return implicitDependencies.isEmpty() ? explicitDependencies() : Sets.union(implicitDependencies, explicitDependencies()); }
From source file:grakn.core.graql.reasoner.plan.GraqlTraversalPlanner.java
/** * @param query top level query for which the plan is constructed * @param atoms list of current atoms of interest * @param subs extra substitutions// w w w. j av a2 s. c om * @return an optimally ordered list of provided atoms */ private static List<Atom> refinePlan(ReasonerQueryImpl query, List<Atom> atoms, Set<IdPredicate> subs) { List<Atom> candidates = subs.isEmpty() ? atoms : atoms.stream().filter(at -> at.getPredicates(IdPredicate.class).findFirst().isPresent()) .collect(Collectors.toList()); ImmutableList<Atom> initialPlan = planFromTraversal(atoms, atomsToPattern(atoms, subs), query.tx()); if (candidates.contains(initialPlan.get(0)) || candidates.isEmpty()) { return initialPlan; } else { Atom first = optimalCandidate(candidates); List<Atom> atomsToPlan = new ArrayList<>(atoms); if (first != null) { atomsToPlan.remove(first); Set<IdPredicate> extraSubs = first.getVarNames().stream() .filter(v -> subs.stream().noneMatch(s -> s.getVarName().equals(v))) .map(v -> IdPredicate.create(v, ConceptId.of(PLACEHOLDER_ID), query)) .collect(Collectors.toSet()); return Stream .concat(Stream.of(first), refinePlan(query, atomsToPlan, Sets.union(subs, extraSubs)).stream()) .collect(Collectors.toList()); } else { return refinePlan(query, atomsToPlan, subs); } } }
From source file:com.opengamma.strata.calc.runner.FunctionRequirements.java
/** * Combines these requirements with another set. * <p>// w w w.ja v a2 s .c o m * The result contains the union of the two sets of requirements. * * @param other the other requirements * @return the combined requirements */ public FunctionRequirements combinedWith(FunctionRequirements other) { return builder().valueRequirements(Sets.union(valueRequirements, other.valueRequirements)) .timeSeriesRequirements(Sets.union(timeSeriesRequirements, other.timeSeriesRequirements)) .outputCurrencies(Sets.union(outputCurrencies, other.outputCurrencies)) .observableSource(!this.observableSource.equals(ObservableSource.NONE) ? this.observableSource : other.observableSource) .build(); }