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.facebook.buck.android.dalvik.firstorder.FirstOrderTypeInfo.java

private FirstOrderTypeInfo(Type type, Type superType, Iterable<Type> interfaceTypes,
        Iterable<Type> observedDependencies) {
    this.type = type;
    this.superType = superType;
    this.interfaceTypes = ImmutableSet.copyOf(interfaceTypes);
    this.observedDependencies = ImmutableSet.copyOf(observedDependencies);
}

From source file:codecrafter47.bungeetablistplus.tablist.GenericServerGroup.java

public GenericServerGroup(Collection<String> servers, String name) {
    this.serverNames = ImmutableSet.copyOf(servers);
    this.name = name;
    this.filter = (viewer, player) -> player.getServer().map(server -> serverNames.contains(server.getName()))
            .orElse(false);/*from   ww  w  . j  a v  a  2 s.  co  m*/
}

From source file:com.github.jcustenborder.kafka.connect.utils.config.validators.ValidCharset.java

public ValidCharset(Iterable<String> charsets) {
    this.allowedCharsets = ImmutableSet.copyOf(charsets);
}

From source file:com.cloudera.oryx.common.settings.InboundSettings.java

public static InboundSettings create(Config config) {
    Config inbound = config.getConfig("inbound");

    List<String> columnNames;
    if (inbound.hasPath("column-names")) {
        columnNames = inbound.getStringList("column-names");
    } else {/*from   www  .j av a2 s .c o  m*/
        int numColumns = inbound.getInt("num-columns");
        columnNames = Lists.newArrayListWithCapacity(numColumns);
        for (int i = 0; i < numColumns; i++) {
            columnNames.add(String.valueOf(i));
        }
    }

    Function<Object, Integer> lookup = new LookupFunction(columnNames);

    Iterable<Integer> allColumns = Collections2.transform(columnNames, lookup);

    Collection<Integer> idColumns;
    if (inbound.hasPath("id-columns")) {
        idColumns = ImmutableSet.copyOf(Collections2.transform(inbound.getAnyRefList("id-columns"), lookup));
    } else {
        idColumns = ImmutableSet.of();
    }

    Collection<Integer> ignoredColumns;
    if (inbound.hasPath("ignored-columns")) {
        ignoredColumns = ImmutableSet
                .copyOf(Collections2.transform(inbound.getAnyRefList("ignored-columns"), lookup));
    } else {
        ignoredColumns = ImmutableSet.of();
    }

    Collection<Integer> categoricalColumns;
    Collection<Integer> numericColumns;
    if (inbound.hasPath("categorical-columns")) {
        Preconditions.checkState(!inbound.hasPath("numeric-columns"));
        categoricalColumns = Sets
                .newHashSet(Collections2.transform(inbound.getAnyRefList("categorical-columns"), lookup));
        numericColumns = Sets.newHashSet(allColumns);
        numericColumns.removeAll(categoricalColumns);
    } else if (inbound.hasPath("numeric-columns")) {
        Preconditions.checkState(!inbound.hasPath("categorical-columns"));
        numericColumns = Sets
                .newHashSet(Collections2.transform(inbound.getAnyRefList("numeric-columns"), lookup));
        categoricalColumns = Sets.newHashSet(allColumns);
        categoricalColumns.removeAll(numericColumns);
    } else {
        throw new IllegalArgumentException("No categorical-columns or numeric-columns set");
    }
    numericColumns.removeAll(idColumns);
    numericColumns.removeAll(ignoredColumns);
    categoricalColumns.removeAll(idColumns);
    categoricalColumns.removeAll(ignoredColumns);

    Integer targetColumn = null;
    if (inbound.hasPath("target-column")) {
        targetColumn = lookup.apply(inbound.getAnyRef("target-column"));
        Preconditions.checkState(
                categoricalColumns.contains(targetColumn) || numericColumns.contains(targetColumn),
                "Target column not specified as numeric or categorical");
    }

    return new InboundSettings(columnNames, idColumns, categoricalColumns, numericColumns, ignoredColumns,
            targetColumn);
}

From source file:com.facebook.presto.sql.parser.DelimiterLexer.java

public DelimiterLexer(CharStream input, Set<String> delimiters) {
    super(input);
    this.delimiters = ImmutableSet.copyOf(delimiters);
}

From source file:org.jclouds.location.config.ProvideRegionsViaProperties.java

@Inject
ProvideRegionsViaProperties(@Named(PROPERTY_REGIONS) String regions) {
    this.regions = ImmutableSet.copyOf(Splitter.on(',').split(regions));
}

From source file:com.eucalyptus.autoscaling.groups.AutoScalingGroupMetricsView.java

public AutoScalingGroupMetricsView(final AutoScalingGroup group) {
    super(group);
    this.enabledMetrics = ImmutableSet.copyOf(group.getEnabledMetrics());
}

From source file:com.google.gxp.base.GxpAttrBundle.java

GxpAttrBundle(Map<String, T> attrs, Set<String> booleanAttrs) {
    this.attrs = ImmutableMap.copyOf(attrs);
    this.booleanAttrs = ImmutableSet.copyOf(booleanAttrs);
}

From source file:org.gbif.api.model.metrics.cube.Rollup.java

public Rollup(Set<Dimension<?>> components) {
    this.dimensions = ImmutableSet.copyOf(components); // defensive copy
}

From source file:org.opendaylight.controller.cluster.raft.messages.ChangeServersVotingStatus.java

public ChangeServersVotingStatus(@Nonnull Map<String, Boolean> serverVotingStatusMap,
        @Nonnull Collection<String> serversVisited) {
    this.serverVotingStatusMap = new HashMap<>(Preconditions.checkNotNull(serverVotingStatusMap));
    this.serversVisited = ImmutableSet.copyOf(Preconditions.checkNotNull(serversVisited));
}