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:grakn.core.graql.executor.property.RelationExecutor.java
@Override public Set<EquivalentFragmentSet> matchFragments() { Collection<Variable> castingNames = new HashSet<>(); ImmutableSet<EquivalentFragmentSet> traversals = property.relationPlayers().stream() .flatMap(relationPlayer -> { Variable castingName = new Variable(); castingNames.add(castingName); return fragmentSetsFromRolePlayer(castingName, relationPlayer); }).collect(ImmutableSet.toImmutableSet()); ImmutableSet<EquivalentFragmentSet> distinctCastingTraversals = castingNames.stream() .flatMap(castingName -> castingNames.stream().filter(otherName -> !otherName.equals(castingName)) .map(otherName -> EquivalentFragmentSets.neq(property, castingName, otherName))) .collect(ImmutableSet.toImmutableSet()); return Sets.union(traversals, distinctCastingTraversals); }
From source file:com.opengamma.strata.function.calculation.swap.AbstractSwapFunction.java
@Override public FunctionRequirements requirements(SwapTrade trade) { Swap swap = trade.getProduct();//from w w w . ja v a 2s . c o m Set<Index> indices = swap.allIndices(); Set<ObservableKey> indexRateKeys = indices.stream().map(IndexRateKey::of).collect(toImmutableSet()); Set<MarketDataKey<?>> indexCurveKeys = indices.stream().map(MarketDataKeys::indexCurve) .collect(toImmutableSet()); Set<DiscountCurveKey> discountCurveKeys = swap.getLegs().stream().map(SwapLeg::getCurrency) .map(DiscountCurveKey::of).collect(toImmutableSet()); return FunctionRequirements.builder().singleValueRequirements(Sets.union(indexCurveKeys, discountCurveKeys)) .timeSeriesRequirements(indexRateKeys) .outputCurrencies(swap.getLegs().stream().map(SwapLeg::getCurrency).collect(toImmutableSet())) .build(); }
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();/* w w w . j a v a2 s .c o m*/ rightArg = node.getRightArg(); getVarCounts(node); assuredBindingNames = new HashSet<>(leftArgVarCounts.keySet()); bindingNames = new HashSet<>(Sets.union(assuredBindingNames, unboundVars)); }
From source file:at.ac.univie.isc.asio.security.Role.java
private Role(final Role parent, final Permission... permissions) { final ImmutableSet<Permission> exclusive = ImmutableSet.copyOf(permissions); if (parent == null) { this.permissions = exclusive; } else { // include parent's permissions this.permissions = ImmutableSet.copyOf(Sets.union(exclusive, parent.getGrantedAuthorities())); }//w ww.ja v a 2s . c o m authority = PREFIX + name(); }
From source file:com.opengamma.strata.function.calculation.rate.swap.AbstractSwapFunction.java
@Override public FunctionRequirements requirements(SwapTrade trade) { Swap swap = trade.getProduct();//from w ww. j av a 2 s. c om Set<Index> indices = swap.allIndices(); Set<ObservableKey> indexRateKeys = indices.stream().map(IndexRateKey::of).collect(toImmutableSet()); Set<MarketDataKey<?>> indexCurveKeys = indices.stream().map(MarketDataKeys::indexCurve) .collect(toImmutableSet()); Set<DiscountFactorsKey> discountCurveKeys = swap.getLegs().stream().map(SwapLeg::getCurrency) .map(DiscountFactorsKey::of).collect(toImmutableSet()); return FunctionRequirements.builder().singleValueRequirements(Sets.union(indexCurveKeys, discountCurveKeys)) .timeSeriesRequirements(indexRateKeys) .outputCurrencies(swap.getLegs().stream().map(SwapLeg::getCurrency).collect(toImmutableSet())) .build(); }
From source file:net.derquinse.bocas.SeededBocas.java
@Override public Set<ByteString> contained(Iterable<ByteString> keys) { final Set<ByteString> requested = getRequested(keys); if (requested.isEmpty()) { return ImmutableSet.of(); }/*from w ww . j a v a2 s . co m*/ Set<ByteString> inPrimary = primary.contained(requested); Set<ByteString> askSeed = Sets.difference(requested, inPrimary).immutableCopy(); if (askSeed.isEmpty()) { return inPrimary; } Set<ByteString> inSecondary = seed.contained(askSeed); return Sets.union(inPrimary, inSecondary).immutableCopy(); }
From source file:com.github.fhirschmann.clozegen.lib.util.UIMAUtils.java
/** * Creates a {@link GapAnnotation} from {@code validAnswers} and * {@code invalidAnswers}. The resulting list of all answer options * of a gap will be composed of union of {@code validAnswers} and * {@code invalidAnswers} in random order. * * @param aJCas The {@link JCas} this Annotation belongs to * @param validAnswers the valid answers for this gap * @param invalidAnswers the invalid answers for this gap * @return a new {@link GapAnnotation}/*from w ww. jav a2 s . c o m*/ */ public static GapAnnotation createGapAnnotation(final JCas aJCas, final Set<String> validAnswers, final Set<String> invalidAnswers) { final GapAnnotation annotation = new GapAnnotation(aJCas); final List<String> allAnswers = Lists.newArrayList(Sets.union(invalidAnswers, validAnswers)); Collections.shuffle(allAnswers); final NonEmptyStringList all = (NonEmptyStringList) FSCollectionFactory.createStringList(aJCas, allAnswers); annotation.setAllAnswers(all); final NonEmptyStringList valid = (NonEmptyStringList) FSCollectionFactory.createStringList(aJCas, validAnswers); annotation.setValidAnswers(valid); return annotation; }
From source file:org.apache.lens.cube.parse.CandidateDim.java
@Override public Collection<String> getColumns() { return Sets.union(dimtable.getAllFieldNames(), dimtable.getPartCols()); }
From source file:org.sosy_lab.cpachecker.cfa.ast.c.CIdExpressionCollectingVisitor.java
@Override public Set<CIdExpression> visit(CExpressionAssignmentStatement pS) throws RuntimeException { return Sets.union(pS.getLeftHandSide().accept(this), pS.getRightHandSide().accept(this)); }
From source file:com.github.nethad.clustermeister.provisioning.ec2.CredentialsManager.java
/** * Get {@link Credentials} by name.// w ww. j a va 2s .c o m * * @param name the name of the credentials (e.g. the configured name). * @return the credentials with the corresponding name or null if none is found. */ public Credentials getCredentials(final String name) { SetView<Credentials> union = Sets.union(configuredCredentials, getNodeKeyPairs()); Credentials result = Iterables.find(union, new Predicate<Credentials>() { @Override public boolean apply(Credentials input) { return input.getName().equals(name); } }, null); return result; }