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:com.facebook.presto.util.GenerateTimeZoneIndex.java
public static void main(String[] args) throws InterruptedException { ////from www . j a v a 2 s .c o m // Header // System.out.println("#"); System.out.println("# DO NOT REMOVE OR MODIFY EXISTING ENTRIES"); System.out.println("#"); System.out.println("# This file contain the fixed numeric id of every supported time zone id."); System.out.println("# Every zone id in this file must be supported by java.util.TimeZone and the"); System.out.println("# Joda time library. This is because Presto uses both java.util.TimeZone and"); System.out.println("# the Joda time## for during execution."); System.out.println("#"); System.out.println("# suppress inspection \"UnusedProperty\" for whole file"); // // We assume 0 is UTC and do not generate it // // // Negative offset // short nextZoneKey = 1; for (int offset = 14 * 60; offset > 0; offset--) { String zoneId = String.format("-%02d:%02d", offset / 60, abs(offset % 60)); short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } // // Positive offset // for (int offset = 1; offset <= 14 * 60; offset++) { String zoneId = String.format("+%02d:%02d", offset / 60, abs(offset % 60)); short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } // // IANA regional zones: region/city // TreeSet<String> jodaZones = new TreeSet<>(DateTimeZone.getAvailableIDs()); TreeSet<String> jdkZones = new TreeSet<>(Arrays.asList(TimeZone.getAvailableIDs())); TreeSet<String> zoneIds = new TreeSet<>(filter(intersection(jodaZones, jdkZones), not(ignoredZone()))); for (String zoneId : zoneIds) { if (zoneId.indexOf('/') < 0) { continue; } short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } // // Other zones // for (String zoneId : zoneIds) { if (zoneId.indexOf('/') >= 0) { continue; } short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } System.out.println(); System.out.println("# Zones not supported in Java"); for (String invalidZone : filter(Sets.difference(jodaZones, jdkZones), not(ignoredZone()))) { System.out.println("# " + invalidZone); } System.out.println(); System.out.println("# Zones not supported in Joda"); for (String invalidZone : filter(Sets.difference(jdkZones, jodaZones), not(ignoredZone()))) { System.out.println("# " + invalidZone); } Thread.sleep(1000); }
From source file:com.eightkdata.mongowp.messages.AssertSetsUtil.java
public static <T> boolean assertSetsEqual(Set<T> a, Set<T> b) { if (a == null || b == null) { return a == b; }/* w w w.ja v a 2 s . c o m*/ Set<T> diff1 = Sets.difference(a, b); Set<T> diff2 = Sets.difference(b, a); return diff1.size() == 0 && diff1.size() == diff2.size(); }
From source file:com.opengamma.language.config.ConfigurationDelta.java
public static ConfigurationDelta of(final Collection<ConfigurationItem> first, final Collection<ConfigurationItem> second) { final Set<ConfigurationItem> firstSet = (first != null) ? new HashSet<ConfigurationItem>(first) : Collections.<ConfigurationItem>emptySet(); final Set<ConfigurationItem> secondSet = (second != null) ? new HashSet<ConfigurationItem>(second) : Collections.<ConfigurationItem>emptySet(); return new ConfigurationDelta(Sets.difference(secondSet, firstSet), Sets.difference(firstSet, secondSet)); }
From source file:com.netflix.lipstick.test.util.Util.java
public static <T> SetView<T> safeDiffSets(Set<T> left, Set<T> right) { if (left == null) { left = new HashSet<T>(); }//from w ww . j a v a2 s . c o m if (right == null) { right = new HashSet<T>(); } return Sets.difference(left, right); }
From source file:org.eclipse.buildship.core.workspace.internal.ManagedModelMergingStrategy.java
/** * Calculates the updated state./*from w w w . j a v a 2s. co m*/ * * @param current elements currently defined on the project * @param model elements defined in the Gradle model * @param managed elements managed by Buildship * @return the description of the updated state */ public static <T> Result<T> calculate(Set<T> current, Set<T> model, Set<T> managed) { Set<T> missing = Sets.difference(current, model); Set<T> removed = Sets.intersection(missing, managed); Set<T> notRemoved = Sets.difference(missing, removed); Set<T> added = Sets.difference(model, current); Set<T> nextElements = Sets.union(model, notRemoved); Set<T> nextManaged = Sets.difference(Sets.union(managed, added), removed); return new Result<T>(nextElements, nextManaged); }
From source file:org.apache.bookkeeper.common.testing.MoreAsserts.java
public static <T> void assertSetEquals(Set<T> expected, Set<T> actual) { SetView<T> diff = Sets.difference(expected, actual); assertTrue("Expected set contains items not exist at actual set : " + diff.immutableCopy(), diff.isEmpty()); diff = Sets.difference(actual, expected); assertTrue("Actual set contains items not exist at expected set : " + diff.immutableCopy(), diff.isEmpty()); }
From source file:com.collective.celos.ci.testing.fixtures.compare.CompareHelper.java
public static <T> FixObjectCompareResult compareEntityNumber(TestRun testRun, FixObjectCreator actualDataCreator, FixObjectCreator expectedDataCreator, Map<T, Integer> expectedRes, Map<T, Integer> actualRes) throws Exception { Set<Map.Entry<T, Integer>> expectedDiffers = Sets.difference(expectedRes.entrySet(), actualRes.entrySet()); Set<Map.Entry<T, Integer>> actualDiffers = Sets.difference(actualRes.entrySet(), expectedRes.entrySet()); if (actualDiffers.size() + expectedDiffers.size() > 0) { String actualDir = getDifference(actualDiffers); String expectedDiff = getDifference(expectedDiffers); return FixObjectCompareResult.failed( "Diff:\n" + "Actual [" + actualDataCreator.getDescription(testRun) + "]:\n" + actualDir + "\n" + "Expected [" + expectedDataCreator.getDescription(testRun) + "]:\n" + expectedDiff); }/* w w w .java2 s . c o m*/ return FixObjectCompareResult.SUCCESS; }
From source file:io.fd.maintainer.plugin.util.WarningGenerator.java
static Set<ComponentWithPath> getInvalidComponents(final MaintainersIndex mappingIndex, final Map.Entry<PatchListEntry, Tuple2<Set<ComponentPath>, Set<ComponentPath>>> entry) { final Set<ComponentPath> oldComponents = entry.getValue().a; final Set<ComponentPath> newComponents = entry.getValue().b; final Sets.SetView<ComponentPath> difference = Sets.difference(oldComponents, newComponents); return difference.immutableCopy().stream() .map(path -> new ComponentWithPath(mappingIndex.getComponentForPath(path), path)) .collect(Collectors.toSet()); }
From source file:org.jamocha.dn.compiler.ecblocks.ActionlistSymbolCollector.java
public static Set<VariableSymbol> getUnboundSymbols(final FunctionWithArguments<SymbolLeaf>[] actionList) { final ActionlistSymbolCollector instance = new ActionlistSymbolCollector(); for (final FunctionWithArguments<SymbolLeaf> fwa : actionList) { fwa.accept(instance);/*from w ww. j a va2 s . co m*/ } return Sets.difference(instance.symbols, instance.boundSymbols); }
From source file:com.google.devtools.build.xcode.util.Difference.java
/** * Returns the elements in set1 which are not in set2. set2 may contain extra elements which will * be ignored.// ww w . ja v a 2s . c o m * * @param set1 Set whose elements to return * @param set2 Set whose elements are to be subtracted */ public static <T> Set<T> of(Set<T> set1, Set<T> set2) { return Sets.difference(set1, set2); }