Example usage for com.google.common.collect ImmutableSet copyOf

List of usage examples for com.google.common.collect ImmutableSet copyOf

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet copyOf.

Prototype

public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements) 

Source Link

Usage

From source file:org.trancecode.collection.TcSets.java

public static <T> ImmutableSet<T> immutableSet(final Iterable<T> set, final T element) {
    Preconditions.checkNotNull(set);//from w  ww .  jav a 2s  . c  om
    Preconditions.checkNotNull(element);

    if (set instanceof Set && ((Set<?>) set).contains(element)) {
        return ImmutableSet.copyOf(set);
    }

    final Builder<T> builder = ImmutableSet.builder();
    return builder.addAll(set).add(element).build();
}

From source file:com.google.errorprone.bugpatterns.threadsafety.AnnotationInfo.java

public static AnnotationInfo create(String typeName, Iterable<String> containerOf) {
    return new AutoValue_AnnotationInfo(typeName, ImmutableSet.copyOf(containerOf));
}

From source file:org.gradle.api.internal.tasks.compile.incremental.deps.DefaultDependentsSet.java

public static DefaultDependentsSet dependents(String... dependentClasses) {
    return new DefaultDependentsSet(ImmutableSet.copyOf(dependentClasses));
}

From source file:com.google.template.soy.jssrc.dsl.Leaf.java

static Leaf create(JsExpr value, Iterable<GoogRequire> requires) {
    return new AutoValue_Leaf(value, ImmutableSet.copyOf(requires));
}

From source file:com.preferanser.shared.util.GameUtils.java

public static Map<Hand, Set<Card>> copyDefensive(Multimap<Hand, Card> handCardMultimap) {
    ImmutableMap.Builder<Hand, Set<Card>> builder = ImmutableMap.builder();

    if (handCardMultimap.containsKey(Hand.EAST))
        builder.put(Hand.EAST, ImmutableSet.copyOf(handCardMultimap.get(Hand.EAST)));
    else//from   w w  w  . ja va  2s.c  o  m
        builder.put(Hand.EAST, ImmutableSet.<Card>of());

    if (handCardMultimap.containsKey(Hand.SOUTH))
        builder.put(Hand.SOUTH, ImmutableSet.copyOf(handCardMultimap.get(Hand.SOUTH)));
    else
        builder.put(Hand.SOUTH, ImmutableSet.<Card>of());

    if (handCardMultimap.containsKey(Hand.WEST))
        builder.put(Hand.WEST, ImmutableSet.copyOf(handCardMultimap.get(Hand.WEST)));
    else
        builder.put(Hand.WEST, ImmutableSet.<Card>of());

    return builder.build();
}

From source file:com.google.devtools.moe.client.Utils.java

/**
 * Returns a Set that excludes strings matching any of excludeRes.
 *//* ww  w . j  a va 2s .c om*/
public static Set<String> filterByRegEx(Set<String> c, List<String> excludeRes) {
    return ImmutableSet.copyOf(Sets.filter(c, nonMatchingPredicateFromRes(excludeRes)));
}

From source file:com.spotify.heroic.common.Optionals.java

public static <T> Optional<Set<T>> mergeOptionalSet(final Optional<Set<T>> a, Optional<Set<T>> b) {
    return mergeOptional(a, b, (al, bl) -> ImmutableSet.copyOf(Iterables.concat(al, bl)));
}

From source file:dagger.internal.codegen.BindingNodeImpl.java

static BindingNode create(ComponentPath component, dagger.model.Binding binding,
        Iterable<BindingDeclaration> associatedDeclarations, Supplier<String> toStringFunction) {
    BindingNodeImpl node = new AutoValue_BindingNodeImpl(component, binding,
            ImmutableSet.copyOf(associatedDeclarations));
    node.toStringFunction = checkNotNull(toStringFunction);
    return node;/*from  w ww . j  a  v  a2  s .  c om*/
}

From source file:com.tngtech.archunit.base.PackageMatchers.java

@PublicAPI(usage = ACCESS)
public static PackageMatchers of(String... packageIdentifiers) {
    return of(ImmutableSet.copyOf(packageIdentifiers));
}

From source file:com.google.doubleclick.openrtb.MapperUtil.java

@SuppressWarnings("unchecked")
public static <T> ImmutableSet<T>[] multimapIntToSets(ImmutableMultimap<Integer, T> mmap) {
    int iMax = Collections.max(mmap.keySet());
    ImmutableSet<T>[] setArray = new ImmutableSet[iMax + 1];
    for (Integer key : mmap.keySet()) {
        setArray[key] = ImmutableSet.copyOf(mmap.get(key));
    }//from  w ww.  j  a  v  a2s  .  com
    return setArray;
}