List of usage examples for com.google.common.collect ImmutableSet copyOf
public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements)
From source file:com.facebook.buck.core.cell.impl.DistributedCellProviderFactory.java
public static CellProvider create(DistBuildCellParams rootCell, ImmutableMap<Path, DistBuildCellParams> cellParams) { Map<String, Path> cellPaths = cellParams.values().stream().filter(p -> p.getCanonicalName().isPresent()) .collect(Collectors.toMap(p -> p.getCanonicalName().get(), p -> p.getFilesystem().getRootPath())); ImmutableSet<String> declaredCellNames = ImmutableSet.copyOf(cellPaths.keySet()); Path rootCellPath = rootCell.getFilesystem().getRootPath(); DefaultCellPathResolver rootCellResolver = DefaultCellPathResolver.of(rootCellPath, cellPaths); return new CellProvider(cellProvider -> CacheLoader.from(cellPath -> { DistBuildCellParams cellParam = Preconditions.checkNotNull(cellParams.get(cellPath), "This should only be called for secondary cells."); Path currentCellRoot = cellParam.getFilesystem().getRootPath(); Preconditions.checkState(!currentCellRoot.equals(rootCellPath)); CellPathResolver currentCellResolver = rootCellResolver; // The CellPathResolverView is required because it makes the // [RootPath<->CanonicalName] resolver methods non-symmetrical to handle the // fact/*from w w w . ja v a2s . c om*/ // that relative main cell from inside a secondary cell resolves actually to // secondary cell. If the DefaultCellPathResolver is used, then it would return // a BuildTarget as if it belonged to the main cell. currentCellResolver = new CellPathResolverView(rootCellResolver, declaredCellNames, currentCellRoot); BuckConfig configWithResolver = cellParam.getConfig().withCellPathResolver(currentCellResolver); RuleKeyConfiguration ruleKeyConfiguration = ConfigRuleKeyConfigurationFactory.create(configWithResolver, cellParam.getBuckModuleManager()); ToolchainProvider toolchainProvider = new DefaultToolchainProvider(cellParam.getPluginManager(), cellParam.getEnvironment(), configWithResolver, cellParam.getFilesystem(), cellParam.getProcessExecutor(), cellParam.getExecutableFinder(), ruleKeyConfiguration); return ImmutableCell.of(cellParams.keySet(), // Distributed builds don't care about cell names, use a sentinel value that // will show up if it actually does care about them. cellParam.getCanonicalName(), WatchmanFactory.NULL_WATCHMAN, cellProvider, toolchainProvider, ruleKeyConfiguration, cellParam.getFilesystem(), configWithResolver); }), cellProvider -> RootCellFactory.create(cellProvider, rootCellResolver, rootCell.getFilesystem(), rootCell.getBuckModuleManager(), rootCell.getPluginManager(), rootCell.getConfig(), rootCell.getEnvironment(), rootCell.getProcessExecutor(), rootCell.getExecutableFinder(), WatchmanFactory.NULL_WATCHMAN)); }
From source file:org.apache.brooklyn.rest.transform.EffectorTransformer.java
public static EffectorSummary effectorSummary(final Entity entity, Effector<?> effector) { String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); return new EffectorSummary(effector.getName(), effector.getReturnTypeName(), ImmutableSet.copyOf(Iterables.transform(effector.getParameters(), new Function<ParameterType<?>, EffectorSummary.ParameterSummary<?>>() { @Override public EffectorSummary.ParameterSummary<?> apply( @Nullable ParameterType<?> parameterType) { return parameterSummary(entity, parameterType); }//from w ww . ja v a 2 s .c o m })), effector.getDescription(), ImmutableMap.of("self", URI.create(entityUri + "/effectors/" + effector.getName()), "entity", URI.create(entityUri), "application", URI.create(applicationUri))); }
From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java
/** * Tests whether a constraint is satisfied by attributes. * * @param attributes Host attributes.// w ww . j a va 2 s . c om * @param constraint Constraint to match. * @return {@code true} if the attribute satisfies the constraint, {@code false} otherwise. */ static boolean matches(Set<Attribute> attributes, IValueConstraint constraint) { Set<String> allAttributes = ImmutableSet .copyOf(Iterables.concat(Iterables.transform(attributes, GET_VALUES))); boolean match = Iterables.any(constraint.getValues(), Predicates.in(allAttributes)); return constraint.isNegated() ^ match; }
From source file:ai.grakn.graql.internal.gremlin.spanningtree.graph.SparseWeightedGraph.java
public static <T> SparseWeightedGraph<T> from(Iterable<T> nodes, Iterable<Weighted<DirectedEdge<T>>> edges) { final Map<T, Map<T, Weighted<DirectedEdge<T>>>> incomingEdges = Maps.newHashMap(); for (Weighted<DirectedEdge<T>> edge : edges) { if (!incomingEdges.containsKey(edge.val.destination)) { incomingEdges.put(edge.val.destination, Maps.newHashMap()); }/* w w w . j a v a 2 s . com*/ incomingEdges.get(edge.val.destination).put(edge.val.source, edge); } return new SparseWeightedGraph<>(ImmutableSet.copyOf(nodes), incomingEdges); }
From source file:co.cask.common.cli.completers.DefaultStringsCompleter.java
public DefaultStringsCompleter(Iterable<String> strings) { this.strings = ImmutableSet.copyOf(strings); }
From source file:cc.kave.commons.pointsto.evaluation.measures.F1Measure.java
@Override public double calculate(ICallsRecommender<Query> recommender, Query q, Set<ICoReMethodName> expectation) { Set<ICoReMethodName> proposals = ImmutableSet.copyOf(getProposals(recommender, q)); Measure measure = Measure.newMeasure(expectation, proposals); return measure.getF1(); }
From source file:org.onosproject.segmentrouting.MockMastershipService.java
MockMastershipService(Set<DeviceId> localDevices) {
this.localDevices = ImmutableSet.copyOf(localDevices);
}
From source file:org.apache.twill.api.Hosts.java
public Hosts(Set<String> hosts) { this.hosts = ImmutableSet.copyOf(hosts); }
From source file:org.apache.twill.api.Racks.java
public Racks(Set<String> racks) { this.racks = ImmutableSet.copyOf(racks); }
From source file:org.lenskit.data.entities.EntityDerivation.java
/** * Create a new entity derivation./*from w ww . j a v a2 s . c o m*/ * @param t The derived entity type. * @param src The source types. * @param attr The attribute to derive from. * @return An entity derivation. */ public static EntityDerivation create(EntityType t, Collection<EntityType> src, TypedName<Long> attr) { ImmutableSet<EntityType> sts = ImmutableSet.copyOf(src); return new EntityDerivation(t, sts, attr); }