List of usage examples for com.google.common.collect Sets newHashSet
public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements)
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.utils.data.graphs.Direction.java
/** * Vrt opa?nou orientaci.//w ww . j a v a 2 s . c om * * @param direction * orientace * @return opa?n orientace */ public static Direction getOpposite(final Direction direction) { Preconditions.checkNotNull(direction); final Direction[] values = values(); assert values.length == 2; final Set<Direction> valuesSet = Sets.newHashSet(values); valuesSet.remove(direction); return valuesSet.iterator().next(); }
From source file:com.atlassian.jira.bc.license.MockLicenseRole.java
public MockLicenseRole(final MockLicenseRole copy) { this.id = copy.id; this.groups = Sets.newHashSet(copy.groups); this.name = copy.name; }
From source file:edu.byu.nlp.data.streams.StopWordRemover.java
public static Set<String> twitterStopWords() { return Sets.newHashSet(Files2.open(StopWordRemover.class, TWITTER_STOP_WORDS_FILE)); }
From source file:org.dodgybits.shuffle.android.core.util.EntityUtils.java
public static boolean idsMatch(List<Id> ids1, List<Id> ids2) { final int oldSize = ids1.size(); final int newSize = ids2.size(); if (newSize == 0 && oldSize == 0) { return true; }/*ww w . j a v a 2 s.c om*/ if (newSize != oldSize) { return false; } // check all ids are the same Set<Id> newIds = Sets.newHashSet(ids1); for (Id id : ids2) { if (!newIds.contains(id)) { return false; } } return true; }
From source file:com.cinchapi.concourse.util.TSets.java
/** * Return a Set that contains only the elements that are in both {@code a} * and {@code b}.//from w ww .j a v a2 s . c om * * @param a * @param b * @return the intersection of the Sets */ public static <T> Set<T> intersection(Set<T> a, Set<T> b) { if (a instanceof SortedSet && b instanceof SortedSet) { return sortedIntersection((SortedSet<T>) a, (SortedSet<T>) b); } else { Set<T> intersection = Sets.newLinkedHashSet(); Set<T> smaller = a.size() <= b.size() ? a : b; Set<T> larger = Sets.newHashSet(a.size() > b.size() ? a : b); for (T element : smaller) { if (larger.contains(element)) { intersection.add(element); } } return intersection; } }
From source file:gr.forth.ics.swkm.model2.ModelDiff.java
public static void checkEqual(Model m1, Model m2) { Set<Resource> namedGraphs1 = Sets.newHashSet(m1.namedGraphs()); Set<Resource> namedGraphs2 = Sets.newHashSet(); for (Resource ng : m2.namedGraphs()) { namedGraphs2.add(ng.mappedTo(m1)); }// www .j a va 2 s . c om checkTriplesOfFirstContainedInSecond(m1, m2); checkTriplesOfFirstContainedInSecond(m2, m1); if (!namedGraphs1.equals(namedGraphs2)) { throw new AssertionError("Not equal named graphs: " + namedGraphs1 + " vs " + namedGraphs2); } }
From source file:com.metamx.druid.query.Queries.java
public static void verifyAggregations(List<AggregatorFactory> aggFactories, List<PostAggregator> postAggs) { Preconditions.checkNotNull(aggFactories, "aggregations cannot be null"); Preconditions.checkArgument(aggFactories.size() > 0, "Must have at least one AggregatorFactory"); if (postAggs != null && !postAggs.isEmpty()) { Set<String> combinedAggNames = Sets .newHashSet(Lists.transform(aggFactories, new Function<AggregatorFactory, String>() { @Override/*from ww w .j av a 2s. c o m*/ public String apply(@Nullable AggregatorFactory input) { return input.getName(); } })); for (PostAggregator postAgg : postAggs) { Set<String> dependencies = postAgg.getDependentFields(); Set<String> missing = Sets.difference(dependencies, combinedAggNames); Preconditions.checkArgument(missing.isEmpty(), "Missing fields [%s] for postAggregator [%s]", missing, postAgg.getName()); combinedAggNames.add(postAgg.getName()); } } }
From source file:org.fenixedu.cms.domain.PermissionEvaluation.java
public static boolean canDoThis(User user, Site site, Permission... permissions) { HashSet<Permission> requiredPerms = Sets.newHashSet(permissions); if (Group.parse("#managers").isMember(user)) { return true; }//w w w . j a v a 2 s .c om for (Role role : site.getRolesSet()) { Set<Permission> availablePerms = role.getRoleTemplate().getPermissions().get(); Set<Permission> intersection = Sets.intersection(availablePerms, requiredPerms); if (!intersection.isEmpty() && role.getGroup().isMember(user)) { requiredPerms.removeAll(intersection); } } return requiredPerms.isEmpty(); }
From source file:com.citytechinc.cq.clientlibs.api.util.ComponentUtils.java
public static Set<Resource> flattenResourceTree(Resource root, boolean inclusive) { Iterator<Resource> typedResourceIterator = root.getResourceResolver() .findResources(TYPED_COMPONENT_QUERY.replace("{path}", root.getPath()), Query.JCR_SQL2); Set<Resource> flattenedResourceTree = Sets.newHashSet(typedResourceIterator); if (inclusive) { flattenedResourceTree.add(root); }// www.ja va 2s . c om return flattenedResourceTree; }
From source file:objenome.solution.SetMethodsGPEvolved.java
public SetMethodsGPEvolved(DevelopMethod... m) { methods = Sets.newHashSet(m); }