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:com.axemblr.service.cm.models.cm.ServiceList.java

@JsonCreator
public ServiceList(@JsonProperty("items") Set<Service> items) {
    this.items = (items == null) ? ImmutableSet.<Service>of() : ImmutableSet.copyOf(items);
}

From source file:com.spotify.heroic.metric.ResultLimits.java

public static ResultLimits of(ResultLimit... limits) {
    return new ResultLimits(ImmutableSet.copyOf(limits));
}

From source file:org.jclouds.openstack.nova.v1_1.util.NovaUtils.java

/**
 * The traditional way to represent a graph in Java is Map<V, Set<V>>, which is awkward in a
 * number of ways. Guava's Multimap framework makes it easy to handle a mapping from keys to
 * multiple values.//w ww. j av  a 2 s  .  c om
 * <p/>
 * Until we write or discover a gson Multimap deserializer, we may be stuck with this.
 * 
 * TODO: ask on stackoverflow and/or jesse wilson
 */
@Deprecated
public static <K, V> Map<K, Set<V>> toOldSchool(Multimap<K, V> in) {
    ImmutableMap.Builder<K, Set<V>> out = ImmutableMap.<K, Set<V>>builder();
    for (K type : in.keySet())
        out.put(type, ImmutableSet.copyOf(in.get(type)));
    return out.build();
}

From source file:com.axemblr.service.cm.models.events.EventQueryResult.java

@JsonCreator
public EventQueryResult(@JsonProperty("totalResults") long totalResults,
        @JsonProperty("items") Set<Event> items) {
    this.totalResults = totalResults;
    this.items = (items == null) ? ImmutableSet.<Event>of() : ImmutableSet.copyOf(items);
}

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

public static <T> ImmutableSet<T> immutableSet(final Set<T> set1, final Set<T> set2) {
    Preconditions.checkNotNull(set1);/*from ww  w  . j a va  2 s . c o  m*/
    Preconditions.checkNotNull(set2);

    if (set1.isEmpty()) {
        return ImmutableSet.copyOf(set2);
    }

    if (set2.isEmpty()) {
        return ImmutableSet.copyOf(set1);
    }

    final Builder<T> builder = ImmutableSet.builder();
    return builder.addAll(set1).addAll(set2).build();
}

From source file:com.axemblr.service.cm.models.clusters.NameServiceList.java

@JsonCreator
public NameServiceList(@JsonProperty("items") Set<NameService> items) {
    this.items = (items == null) ? ImmutableSet.<NameService>of() : ImmutableSet.copyOf(items);
}

From source file:com.opengamma.engine.marketdata.manipulator.CompositeMarketDataSelector.java

/**
 * Create a composite specification for the specified underlying specifiations.
 *
 * @param specifications the specifications to be combined, neither null nor empty
 * @return a specification combined all the underlying specifications, not null
 *//*from   ww  w  .j a  v  a 2s.  com*/
public static MarketDataSelector of(MarketDataSelector... specifications) {
    return new CompositeMarketDataSelector(ImmutableSet.copyOf(specifications));
}

From source file:org.gradle.api.internal.file.collections.ImmutableFileCollection.java

public static ImmutableFileCollection of(File... files) {
    if (files.length == 0) {
        return EMPTY;
    }/* w w  w  .  j a va  2  s .c o  m*/
    return new FileOnlyImmutableFileCollection(ImmutableSet.copyOf(files));
}

From source file:org.apache.cassandra.db.lifecycle.Helpers.java

/**
 * update the contents of a set with the provided sets, ensuring that the items to remove are
 * really present, and that the items to add are not (unless we're also removing them)
 * @return a new set with the contents of the provided one modified
 */// w  w  w .  ja  v a 2 s . co  m
static <T> Set<T> replace(Set<T> original, Set<T> remove, Iterable<T> add) {
    return ImmutableSet.copyOf(replace(identityMap(original), remove, add).keySet());
}

From source file:ch.acanda.eclipse.pmd.domain.WorkspaceModel.java

public ImmutableSet<ProjectModel> getProjects() {
    return ImmutableSet.copyOf(projects.values());
}