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:ezbake.warehaus.WarehausUtils.java
public static String getAuthsListFromToken(EzSecurityToken token) { ezbake.base.thrift.Authorizations auths = token.getAuthorizations(); Set<String> formalAuths = auths.isSetFormalAuthorizations() ? auths.getFormalAuthorizations() : Sets.<String>newHashSet(); Set<String> externalCommunities = auths.isSetExternalCommunityAuthorizations() ? auths.getExternalCommunityAuthorizations() : Sets.<String>newHashSet(); Set<String> allAuths = Sets.union(formalAuths, externalCommunities); return StringUtils.join(allAuths, ","); }
From source file:nmsu.cs.TwitterDataCleaner.java
/** * Randomly choose dataset of size from the total data. * before extraction manually remove and mkdir the ./twitterSIZE directory * @param size//from www . j a v a2 s. com */ public static void extract_dataset(int size) { File dataset = new File(data_path + "/twitter" + size); Set<File> friend_list_set = new HashSet<File>(); File[] friend_list_dirs = new File(data_path + "/friendList").listFiles(); for (File friend_list_dir : friend_list_dirs) { File[] friend_list_json_files = friend_list_dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".json"); //To change body of implemented methods use File | Settings | File Templates. } }); friend_list_set = Sets.union(new HashSet<File>(Arrays.asList(friend_list_json_files)), friend_list_set); } List<File> friend_list_arr = new ArrayList<File>(friend_list_set); //get map and tweets in String first, the convert to integer. Map<String, List<String>> inf_graph = new HashMap<String, List<String>>(); Set<Set<String>> partition = new HashSet<Set<String>>(); Set<String> aspect_set = new HashSet<String>(); Set<String> objSet = new HashSet<String>(); }
From source file:com.google.gerrit.index.IndexUtils.java
public static Set<String> fields(QueryOptions opts) { // Ensure we request enough fields to construct a ChangeData. We need both // change ID and project, which can either come via the Change field or // separate fields. Set<String> fs = opts.fields(); if (fs.contains(CHANGE.getName())) { // A Change is always sufficient. return fs; }//w w w . j a v a 2s . c om if (fs.contains(PROJECT.getName()) && fs.contains(LEGACY_ID.getName())) { return fs; } return Sets.union(fs, ImmutableSet.of(LEGACY_ID.getName(), PROJECT.getName())); }
From source file:com.siemens.sw360.datahandler.permissions.ComponentPermissions.java
protected ComponentPermissions(Component document, User user) { super(document, user); //Should depend on permissions of contained releases this.createdBy = toSingletonSet(document.createdBy); moderators = Sets.union(toSingletonSet(document.createdBy), CommonUtils.nullToEmptySet(document.moderators)); }
From source file:io.pcp.parfait.dxm.FixedValueIdentifierSource.java
@Override public int calculateId(String name, Set<Integer> usedIds) { Integer reservedId = reservedIds.get(name); if (reservedId == null || usedIds.contains(reservedId)) { return fallback.calculateId(name, Sets.union(usedIds, new HashSet<Integer>(reservedIds.values()))); }// w w w.ja va2s . c om return reservedId; }
From source file:com.github.benmanes.caffeine.cache.local.AddFastPath.java
@Override protected void execute() { boolean fastpath = Feature.usesFastPath(Sets.union(context.parentFeatures, context.generateFeatures)); context.cache//from ww w .ja v a2s. co m .addMethod(MethodSpec.methodBuilder("fastpath").addStatement("return " + Boolean.toString(fastpath)) .addModifiers(Modifier.PROTECTED).returns(boolean.class).build()); }
From source file:com.facebook.buck.jvm.java.DefaultSuggestBuildRules.java
/** * @return A function that takes a list of failed imports from a javac invocation and returns a * set of rules to suggest that the developer import to satisfy those imports. *//*from ww w . j a v a 2s. com*/ static SuggestBuildRules createSuggestBuildFunction(final JarResolver jarResolver, final ImmutableSet<JavaLibrary> declaredDeps, final ImmutableSet<JavaLibrary> transitiveDeps, final Iterable<BuildRule> buildRules) { final Supplier<ImmutableList<JavaLibrary>> sortedTransitiveNotDeclaredDeps = Suppliers .memoize(new Supplier<ImmutableList<JavaLibrary>>() { @Override public ImmutableList<JavaLibrary> get() { Set<JavaLibrary> transitiveNotDeclaredDeps = Sets.difference(transitiveDeps, Sets.union(ImmutableSet.of(this), declaredDeps)); DirectedAcyclicGraph<BuildRule> graph = BuildRuleDependencyVisitors .getBuildRuleDirectedGraphFilteredBy(buildRules, JavaLibrary.class::isInstance, JavaLibrary.class::isInstance); return FluentIterable.from(TopologicalSort.sort(graph)).filter(JavaLibrary.class) .filter(transitiveNotDeclaredDeps::contains).toList().reverse(); } }); return new DefaultSuggestBuildRules(sortedTransitiveNotDeclaredDeps, jarResolver); }
From source file:com.google.devtools.moe.client.tools.CodebaseDiffer.java
/** * Diff two {@link Codebase} instances with a {@link FileDiffer}. *///w ww . j av a 2 s . c om public CodebaseDifference diffCodebases(Codebase codebase1, Codebase codebase2) { Set<String> filenames = Sets.union(codebase1.getRelativeFilenames(), codebase2.getRelativeFilenames()); ImmutableSet.Builder<FileDifference> fileDiffs = ImmutableSet.builder(); for (String filename : filenames) { FileDifference fileDiff = differ.diffFiles(filename, codebase1.getFile(filename), codebase2.getFile(filename)); if (fileDiff.isDifferent()) { fileDiffs.add(fileDiff); } } return new CodebaseDifference(codebase1, codebase2, fileDiffs.build()); }
From source file:com.davidbracewell.math.distance.HammingDistance.java
@Override public double calculate(Map<?, ? extends Number> m1, Map<?, ? extends Number> m2) { Preconditions.checkNotNull(m1, "Vectors cannot be null"); Preconditions.checkNotNull(m2, "Vectors cannot be null"); double sum = 0; for (Object o : Sets.union(m1.keySet(), m2.keySet())) { double d1 = m1.containsKey(o) ? m1.get(o).doubleValue() : 0d; double d2 = m2.containsKey(o) ? m2.get(o).doubleValue() : 0d; if (d1 != d2) { sum++;/*w ww.ja v a2s. co m*/ } } return sum; }
From source file:org.jboss.hal.client.runtime.subsystem.jaxrs.RestResource.java
Set<String> getResourceMethods() {
return Sets.union(resourceMethods(REST_RESOURCE_PATHS), resourceMethods(SUB_RESOURCE_LOCATORS))
.immutableCopy();
}