List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.cloudera.gertrude.space.ExperimentSpaceBuilder.java
private Set<Integer> getLineage(int layerId) { ImmutableSet.Builder<Integer> b = ImmutableSet.builder(); b.add(layerId);//from w w w . j ava 2 s. co m int domainId = layers.get(layerId).getDomainId(); if (domainId > 0) { b.addAll(getLineage(allSegments.get(domainId).getLayerId())); } return b.build(); }
From source file:vazkii.botania.client.model.SpecialFlowerModel.java
@Override public Collection<ResourceLocation> getDependencies() { ImmutableSet.Builder<ResourceLocation> builder = ImmutableSet.builder(); builder.addAll(blockModels.values()); builder.addAll(itemModels.values()); // Force island models to be loaded and baked. See FloatingFlowerModel. builder.addAll(BotaniaAPIClient.getRegisteredIslandTypeModels().values()); return builder.build(); }
From source file:org.spongepowered.lantern.data.LanternDataHolder.java
@Override public Set<ImmutableValue<?>> getValues() { ImmutableSet.Builder<ImmutableValue<?>> builder = ImmutableSet.builder(); containerStore.values().forEach(data -> builder.addAll(data.getValues())); return builder.build(); }
From source file:com.facebook.buck.android.relinker.RelinkerRule.java
private ImmutableSet<String> readSymbolsNeeded() throws IOException { ImmutableSet.Builder<String> symbolsNeeded = ImmutableSet.builder(); for (SourcePath source : symbolsNeededPaths) { symbolsNeeded.addAll(Files.readAllLines(pathResolver.getAbsolutePath(source), Charsets.UTF_8)); }/*from w ww . ja va 2 s. c o m*/ return symbolsNeeded.build(); }
From source file:com.facebook.buck.jvm.java.SrcRootsFinder.java
/** * Source roots for Java code can be specified in one of two ways. They can be given as paths * relative to the root of the project (e.g. "/java/"), or they can be given as slash-less * directory names that can live anywhere in the project (e.g. "src"). Convert these src_root * specifier strings into actual paths, by walking the project and collecting all the matches. * @param pathPatterns the strings obtained from the src_root field of the .buckconfig * @return a set of paths to all the actual source root directories in the project */// w w w . j av a2 s. co m public ImmutableSet<Path> getAllSrcRootPaths(Iterable<String> pathPatterns) throws IOException { ImmutableSet.Builder<Path> srcRootPaths = ImmutableSet.builder(); DefaultJavaPackageFinder finder = DefaultJavaPackageFinder.createDefaultJavaPackageFinder(pathPatterns); for (String pathFromRoot : finder.getPathsFromRoot()) { srcRootPaths.add(Paths.get(pathFromRoot)); } srcRootPaths.addAll(findAllMatchingPaths(finder.getPathElements())); return srcRootPaths.build(); }
From source file:org.sosy_lab.cpachecker.cpa.validvars.ValidVars.java
private Map<String, Set<String>> updateLocalVars(String funName, Collection<String> newLocalVarsNames) { if (newLocalVarsNames != null) { ImmutableMap.Builder<String, Set<String>> builderMap = ImmutableMap.builder(); for (String functionName : localValidVars.keySet()) { if (!functionName.equals(funName)) { builderMap.put(functionName, localValidVars.get(functionName)); }/*from www . j av a 2 s. c o m*/ } ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (localValidVars.containsKey(funName)) { builder.addAll(localValidVars.get(funName)); } builder.addAll(newLocalVarsNames); builderMap.put(funName, builder.build()); return builderMap.build(); } return localValidVars; }
From source file:com.kolich.curacao.mappers.request.RequestMappingTable.java
private static final Set<java.lang.reflect.Method> getAllRequestMappingsInHierarchy(final Class<?> clazz) { final ImmutableSet.Builder<java.lang.reflect.Method> builder = ImmutableSet.builder(); Class<?> superClass = clazz; // <https://github.com/markkolich/curacao/issues/15> // The logic herein crawls up the class hierarchy of a given @Controller // looking for methods annotated with the @RequestMapping annotation. // This is fine, except that when we crawl up the class hierarchy and // get to java.lang.Object we waste cycles looking through // java.lang.Object for any methods annotated with @RequestMapping. // Good times, because there won't be any in java.lang.Object; why // spend cycles using reflection checking java.lang.Object for any // @RequestMapping annotated methods when there won't be any? // We avoid that wasteful check by checking if the super class is // equal to java.lang.Object; if it is, we just skip it because // Object is the guaranteed root of objects in Java. while (superClass != null && !Object.class.equals(superClass)) { final Reflections superClassMethodReflection = getMethodReflectionInstanceForClass(superClass); builder.addAll(superClassMethodReflection.getMethodsAnnotatedWith(RequestMapping.class)); // Will be null for "Object" (base class) superClass = superClass.getSuperclass(); }//from w w w .j a v a2s .com return builder.build(); }
From source file:com.facebook.buck.graph.MutableDirectedGraph.java
public ImmutableSet<ImmutableSet<T>> findCycles() { Set<Set<T>> cycles = Sets.filter(tarjan(), new Predicate<Set<T>>() { @Override/*from www.ja va 2 s. co m*/ public boolean apply(@Nullable Set<T> stronglyConnectedComponent) { return stronglyConnectedComponent.size() > 1; } }); Iterable<ImmutableSet<T>> immutableCycles = Iterables.transform(cycles, new Function<Set<T>, ImmutableSet<T>>() { @Override public ImmutableSet<T> apply(Set<T> cycle) { return ImmutableSet.copyOf(cycle); } }); // Tarjan's algorithm (as pseudo-coded on Wikipedia) does not appear to account for single-node // cycles. Therefore, we must check for them exclusively. ImmutableSet.Builder<ImmutableSet<T>> builder = ImmutableSet.builder(); builder.addAll(immutableCycles); for (T node : nodes) { if (containsEdge(node, node)) { builder.add(ImmutableSet.of(node)); } } return builder.build(); }
From source file:org.onosproject.pipelines.fabric.pipeliner.FabricForwardingPipeliner.java
private void processSpecificFwd(ForwardingObjective fwd, PipelinerTranslationResult.Builder resultBuilder) { TrafficSelector selector = fwd.selector(); TrafficSelector meta = fwd.meta();/* www .j a v a 2 s.c om*/ ImmutableSet.Builder<Criterion> criterionSetBuilder = ImmutableSet.builder(); criterionSetBuilder.addAll(selector.criteria()); if (meta != null) { criterionSetBuilder.addAll(meta.criteria()); } Set<Criterion> criteria = criterionSetBuilder.build(); VlanIdCriterion vlanIdCriterion = null; EthCriterion ethDstCriterion = null; IPCriterion ipDstCriterion = null; MplsCriterion mplsCriterion = null; for (Criterion criterion : criteria) { switch (criterion.type()) { case ETH_DST: ethDstCriterion = (EthCriterion) criterion; break; case VLAN_VID: vlanIdCriterion = (VlanIdCriterion) criterion; break; case IPV4_DST: ipDstCriterion = (IPCriterion) criterion; break; case MPLS_LABEL: mplsCriterion = (MplsCriterion) criterion; break; case ETH_TYPE: case MPLS_BOS: // do nothing break; default: log.warn("Unsupported criterion {}", criterion); break; } } ForwardingFunctionType forwardingFunctionType = ForwardingFunctionType.getForwardingFunctionType(fwd); switch (forwardingFunctionType) { case L2_UNICAST: processL2UnicastRule(vlanIdCriterion, ethDstCriterion, fwd, resultBuilder); break; case L2_BROADCAST: processL2BroadcastRule(vlanIdCriterion, fwd, resultBuilder); break; case IPV4_UNICAST: processIpv4UnicastRule(ipDstCriterion, fwd, resultBuilder); break; case MPLS: processMplsRule(mplsCriterion, fwd, resultBuilder); break; case IPV4_MULTICAST: case IPV6_UNICAST: case IPV6_MULTICAST: default: log.warn("Unsupported forwarding function type {}", criteria); resultBuilder.setError(ObjectiveError.UNSUPPORTED); break; } }
From source file:org.lanternpowered.server.scoreboard.LanternScoreboard.java
@Override public Set<Score> getScores() { final ImmutableSet.Builder<Score> scores = ImmutableSet.builder(); for (Objective objective : this.objectives.values()) { scores.addAll(((LanternObjective) objective).scores.values()); }//from w w w . j a v a2 s .com return scores.build(); }