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: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(); }// w w w .ja v a2s . 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.cognifide.aet.job.common.comparators.cookie.CookieComparator.java
@SuppressWarnings("unchecked") private ComparatorStepResult compareCookies(Set<Cookie> cookies) throws IOException { final Set<Cookie> cookiesPattern = artifactsDAO.getJsonFormatArtifact(properties, properties.getPatternId(), COOKIES_SET_TYPE);// w w w .j a v a 2 s . c om final Set<String> collectedCookiesNames = FluentIterable.from(cookies).transform(COOKIE_STRING_FUNCTION) .toSet(); final Set<String> patternCookiesNames = FluentIterable.from(cookiesPattern) .transform(COOKIE_STRING_FUNCTION).toSet(); Set<String> additionalCookies = Sets.difference(collectedCookiesNames, patternCookiesNames); Set<String> notFoundCookies = Sets.difference(patternCookiesNames, collectedCookiesNames); Set<String> foundCookies = Collections.emptySet(); if (showMatched) { foundCookies = Sets.intersection(patternCookiesNames, collectedCookiesNames); } boolean compareResult = additionalCookies.isEmpty() && notFoundCookies.isEmpty(); CookieCompareComparatorResult result = new CookieCompareComparatorResult(compareAction, cookies, notFoundCookies, additionalCookies, foundCookies); final String artifactId = artifactsDAO.saveArtifactInJsonFormat(properties, result); return new ComparatorStepResult(artifactId, compareResult ? ComparatorStepResult.Status.PASSED : ComparatorStepResult.Status.FAILED, !compareResult); }
From source file:eu.lp0.cursus.test.util.RaceAssertUtil.java
public void assertDone(int expectedSimulatedRacePointsPilots) { Assert.assertFalse(done);//from w w w . jav a 2 s. com Assert.assertArrayEquals(new Object[0], Sets .difference(new HashSet<Pilot>(scores.getSimulatedRacePoints(race)), expectedRaceOrder).toArray()); Assert.assertEquals(expectedSimulatedRacePointsPilots, scores.getSimulatedRacePoints(race).size()); Assert.assertEquals(scores.getPilots().size(), expectedRaceOrder.size()); Assert.assertEquals(scores.getPilots().size(), scores.getRaceOrder(race).size()); Assert.assertArrayEquals(expectedRaceOrder.toArray(), scores.getRaceOrder(race).toArray()); done = true; }
From source file:de.decoit.siemgui.domain.events.NmapEventContent.java
/** * Return a set of ports that are open but should be closed. * These are the ports that caused a CRITICAL status from Nmap. * * @return Set of open ports/*from w w w .j av a2 s . c o m*/ */ @JsonProperty("invalid-open-ports") public Set<Integer> getInvalidOpenPorts() { Set<Integer> rv = Sets.difference(scannedPorts, allowedPorts); return rv; }
From source file:org.eclipse.sw360.moderation.db.ModerationRequestGenerator.java
private Set<String> getAddedStrings(Set<String> actualStrings, Set<String> updateStrings) { return Sets.difference(nullToEmptySet(updateStrings), nullToEmptySet(actualStrings)); }
From source file:auto.http.internal.codegen.AutoHttpWriter.java
private void buildMethods() { for (AutoHttpDescriptor.MethodDescriptor methodDescriptor : autoHttpDescriptor.methodElements()) { ExecutableElement methodElement = methodDescriptor.methodElement(); MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(methodElement.getSimpleName().toString()) .addAnnotation(Override.class) .addModifiers(Sets.difference(methodElement.getModifiers(), ImmutableSet.of(ABSTRACT))) .returns(methodDescriptor.returnTypeName()); String returnType = "returnType"; StringBuilder returnTypeFormat = new StringBuilder("$T $N = $T.wrapType($N.class,"); ImmutableList<Class<?>> returnTypeArguments = methodDescriptor.returnTypeArguments(); for (int i = 0; i < returnTypeArguments.size(); i++) { returnTypeFormat.append(returnTypeArguments.get(i).getSimpleName()); returnTypeFormat.append(".class,"); }/*from w w w . ja v a2 s . c o m*/ returnTypeFormat.deleteCharAt(returnTypeFormat.length() - 1).append(")"); methodBuilder.addStatement(returnTypeFormat.toString(), Type.class, returnType, Utils.class, methodDescriptor.returnType().getSimpleName()); String convertType = "convertType"; StringBuilder convertTypeFormat = new StringBuilder("$T $N = $T.wrapType($N.class,"); ImmutableList<Class<?>> converterTypeArguments = methodDescriptor.converterTypeArguments(); for (int i = 0; i < converterTypeArguments.size(); i++) { convertTypeFormat.append(converterTypeArguments.get(i).getSimpleName()); convertTypeFormat.append(".class,"); } convertTypeFormat.deleteCharAt(convertTypeFormat.length() - 1).append(")"); methodBuilder.addStatement(convertTypeFormat.toString(), Type.class, convertType, Utils.class, methodDescriptor.converterType().getSimpleName()); //TODO method body impl String builder = "builder"; methodBuilder.addStatement("$T $N = new $T()", Request.Builder.class, builder, Request.Builder.class) .addStatement("$N.url($N.baseUrl())", builder, FIELD_PLUGINS) .addStatement("return $T.result($N.build(),$N,$N,$N)", ResultFactory.class, builder, FIELD_PLUGINS, returnType, convertType); autoHttpClass.addMethod(methodBuilder.build()); } }
From source file:org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer.java
@Override public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Capabilities>> changes) { for (DataTreeModification<Capabilities> change : changes) { final DataObjectModification<Capabilities> rootNode = change.getRootNode(); final DataObjectModification.ModificationType modificationType = rootNode.getModificationType(); switch (modificationType) { case WRITE: { final Capabilities dataAfter = rootNode.getDataAfter(); final Capabilities dataBefore = rootNode.getDataBefore(); final Set<Uri> before = dataBefore != null ? ImmutableSet.copyOf(dataBefore.getCapability()) : Collections.emptySet(); final Set<Uri> after = dataAfter != null ? ImmutableSet.copyOf(dataAfter.getCapability()) : Collections.emptySet(); final Set<Uri> added = Sets.difference(after, before); final Set<Uri> removed = Sets.difference(before, after); publishNotification(added, removed); break; }/*www. jav a 2 s .c o m*/ case DELETE: { final Capabilities dataBeforeDelete = rootNode.getDataBefore(); if (dataBeforeDelete != null) { final Set<Uri> removed = ImmutableSet.copyOf(dataBeforeDelete.getCapability()); publishNotification(Collections.emptySet(), removed); } break; } } } }
From source file:com.google.errorprone.bugpatterns.threadsafety.AbstractLockMethodChecker.java
@Override public Description matchMethod(MethodTree tree, final VisitorState state) { ImmutableList<String> lockExpressions = getLockExpressions(tree); if (lockExpressions.isEmpty()) { return Description.NO_MATCH; }/* ww w . j av a 2s .co m*/ Optional<ImmutableSet<GuardedByExpression>> expected = parseLockExpressions(lockExpressions, tree, state); if (!expected.isPresent()) { return buildDescription(tree).setMessage("Could not resolve lock expression.").build(); } Set<GuardedByExpression> unwanted = getUnwanted(tree, state); SetView<GuardedByExpression> mishandled = Sets.intersection(expected.get(), unwanted); if (!mishandled.isEmpty()) { String message = buildMessage(formatLockString(mishandled)); return buildDescription(tree).setMessage(message).build(); } Set<GuardedByExpression> actual = getActual(tree, state); SetView<GuardedByExpression> unhandled = Sets.difference(expected.get(), actual); if (!unhandled.isEmpty()) { String message = buildMessage(formatLockString(unhandled)); return buildDescription(tree).setMessage(message).build(); } return Description.NO_MATCH; }
From source file:blockplus.model.polyomino.PolyominoProperties.java
private static Iterable<IPosition> computeShadows(final Set<IPosition> sides, final Set<IPosition> positions) { return Sets.difference(sides, positions); }
From source file:org.eclipse.sirius.ext.base.collect.GSetIntersection.java
/** * {@inheritDoc} */ @Override public Set<E> getNewElements() { return Sets.difference(newElements, oldElements.values()); }