List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.github.rinde.rinsim.core.model.road.DynamicGraphRoadModelImpl.java
/** * Returns all {@link RoadUser}s that are on the connection between * <code>from</code> and <code>to</code> (inclusive). * @param from The start point of a connection. * @param to The end point of a connection. * @return The {@link RoadUser}s that are on the connection, or an empty set * in case {@link #hasRoadUserOn(Point, Point)} returns * <code>false</code>. * @throws IllegalArgumentException if no connection exists between * <code>from</code> and <code>to</code>. *//* w w w .j a v a 2s . c o m*/ @Override public ImmutableSet<RoadUser> getRoadUsersOn(Point from, Point to) { checkConnectionsExists(from, to); final ImmutableSet.Builder<RoadUser> builder = ImmutableSet.builder(); final Connection<?> conn = graph.getConnection(from, to); if (connMap.containsKey(conn)) { builder.addAll(connMap.get(conn)); } if (posMap.containsKey(from)) { builder.addAll(posMap.get(from)); } if (posMap.containsKey(to)) { builder.addAll(posMap.get(to)); } return builder.build(); }
From source file:org.apache.sentry.provider.common.CacheProvider.java
public ImmutableSet<String> getPrivileges(Set<String> groups, ActiveRoleSet roleSet, Authorizable... authorizableHierarchy) { if (!initialized) { throw new IllegalStateException("CacheProvider has not been properly initialized"); }//from w ww .java2 s .co m ImmutableSet.Builder<String> resultBuilder = ImmutableSet.builder(); for (String groupName : groups) { for (Map.Entry<String, Set<String>> row : cache.getCache().row(groupName).entrySet()) { if (roleSet.containsRole(row.getKey())) { // TODO: SENTRY-1245: Filter by Authorizables, if provided resultBuilder.addAll(row.getValue()); } } } return resultBuilder.build(); }
From source file:org.jclouds.aliyun.ecs.compute.ECSComputeServiceAdapter.java
@Override public Iterable<InstanceType> listHardwareProfiles() { final ImmutableSet.Builder<String> instanceTypeIdsBuilder = ImmutableSet.builder(); for (String regionId : getAvailableLocationNames()) { instanceTypeIdsBuilder.addAll(getInstanceTypeIds(regionId)); }//from ww w .j a v a 2s. c o m final Set<String> ids = instanceTypeIdsBuilder.build(); List<InstanceType> instanceTypes = FluentIterable.from(api.instanceApi().listTypes()) .filter(new Predicate<InstanceType>() { @Override public boolean apply(@Nullable InstanceType input) { return contains(ids, input.id()); } }).toList(); return instanceTypes; }
From source file:ai.grakn.graql.internal.gremlin.fragment.Fragment.java
/** * Get all variables in the fragment including the start and end (if present) *//*from w ww. j a va2 s.c om*/ public final Set<Var> vars() { ImmutableSet.Builder<Var> builder = ImmutableSet.<Var>builder().add(start()); Var end = end(); if (end != null) builder.add(end); builder.addAll(otherVars()); return builder.build(); }
From source file:com.facebook.buck.cxx.CxxBinaryDescription.java
public Iterable<BuildTarget> findDepsForTargetFromConstructorArgs(BuildTarget buildTarget, CellPathResolver cellRoots, ImmutableList<String> linkerFlags, ImmutableList<ImmutableList<String>> platformLinkerFlags) { ImmutableSet.Builder<BuildTarget> deps = ImmutableSet.builder(); // Get any parse time deps from the C/C++ platforms. deps.addAll(CxxPlatforms .getParseTimeDeps(cxxPlatforms.getValue(buildTarget.getFlavors()).orElse(defaultCxxPlatform))); ImmutableList<ImmutableList<String>> macroStrings = ImmutableList.<ImmutableList<String>>builder() .add(linkerFlags).addAll(platformLinkerFlags).build(); for (String macroString : Iterables.concat(macroStrings)) { try {/*from w ww .j ava2 s . c o m*/ deps.addAll(CxxDescriptionEnhancer.MACRO_HANDLER.extractParseTimeDeps(buildTarget, cellRoots, macroString)); } catch (MacroException e) { throw new HumanReadableException(e, "%s: %s", buildTarget, e.getMessage()); } } return deps.build(); }
From source file:org.androidtransfuse.processor.TransfuseProcessor.java
public void logErrors() { boolean errored = false; ImmutableSet.Builder<Exception> exceptions = ImmutableSet.builder(); for (TransactionProcessorBuilder transactionProcessor : generatorRepository.getComponentBuilders() .values()) {/*from w ww.ja v a2 s .c o m*/ if (!transactionProcessor.getTransactionProcessor().isComplete()) { errored = true; exceptions.addAll(transactionProcessor.getTransactionProcessor().getErrors()); } } if (errored) { if (stacktrace) { for (Exception exception : exceptions.build()) { log.error("Code generation did not complete successfully.", exception); } } else { log.error( "Code generation did not complete successfully. For more details add the compiler argument -AtransfuseStacktrace"); } } }
From source file:org.graylog2.shared.initializers.RestApiService.java
@Override protected void startUp() throws Exception { ImmutableSet.Builder<Resource> additionalResourcesBuilder = ImmutableSet.<Resource>builder() .addAll(prefixPluginResources(PLUGIN_PREFIX, pluginRestResources)); if (configuration.isWebEnable() && configuration.isRestAndWebOnSamePort()) { additionalResourcesBuilder = additionalResourcesBuilder .addAll(prefixResources(configuration.getWebPrefix(), ImmutableSet.of(webInterfaceAssetsResource.getClass(), appConfigResource.getClass()))); }//from w w w . j a v a 2s . com httpServer = setUp("rest", configuration.getRestListenUri(), configuration.isRestEnableTls(), configuration.getRestTlsCertFile(), configuration.getRestTlsKeyFile(), configuration.getRestTlsKeyPassword(), configuration.getRestThreadPoolSize(), configuration.getRestMaxInitialLineLength(), configuration.getRestMaxHeaderSize(), configuration.isRestEnableGzip(), configuration.isRestEnableCors(), additionalResourcesBuilder.build(), restControllerPackages); httpServer.start(); LOG.info("Started REST API at <{}>", configuration.getRestListenUri()); if (configuration.isWebEnable() && configuration.isRestAndWebOnSamePort()) { LOG.info("Started Web Interface at <{}>", configuration.getWebListenUri()); } }
From source file:org.sosy_lab.cpachecker.cpa.targetreachability.TargetReachabilityCPA.java
private ImmutableSet<CFANode> getReachableNodes(ShutdownNotifier shutdownNotifier, LogManager pLogger, CFA pCfa, Specification pSpecification) {/* w w w . j a v a 2 s . c om*/ TargetLocationProvider targetProvider = new TargetLocationProviderImpl(shutdownNotifier, pLogger, pCfa); if (noFollowBackwardsUnreachable) { backwardsReachability.start(); ImmutableSet.Builder<CFANode> builder = ImmutableSet.builder(); try { Set<CFANode> targetNodes = targetProvider.tryGetAutomatonTargetLocations(pCfa.getMainFunction(), pSpecification); for (CFANode target : targetNodes) { builder.addAll(CFATraversal.dfs().backwards().collectNodesReachableFrom(target)); } } finally { backwardsReachability.stop(); } return builder.build(); } else { return ImmutableSet.copyOf(pCfa.getAllNodes()); } }
From source file:org.sosy_lab.cpachecker.cpa.pointer2.util.ExplicitLocationSet.java
@Override public LocationSet addElements(Iterable<String> pLocations) { ImmutableSet.Builder<String> builder = null; for (String target : pLocations) { if (!explicitSet.contains(target)) { if (builder == null) { builder = ImmutableSet.builder(); builder.addAll(explicitSet); }/*from w w w . j av a 2s .co m*/ builder.add(target); } } if (builder == null) { return this; } return new ExplicitLocationSet(builder.build()); }
From source file:com.facebook.buck.apple.AppleDescriptions.java
static AppleBundle createAppleBundle(FlavorDomain<CxxPlatform> cxxPlatformFlavorDomain, CxxPlatform defaultCxxPlatform, FlavorDomain<AppleCxxPlatform> appleCxxPlatforms, TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, CodeSignIdentityStore codeSignIdentityStore, ProvisioningProfileStore provisioningProfileStore, BuildTarget binary, Either<AppleBundleExtension, String> extension, Optional<String> productName, final SourcePath infoPlist, ImmutableMap<String, String> infoPlistSubstitutions, ImmutableSortedSet<BuildTarget> deps, ImmutableSortedSet<BuildTarget> tests, AppleDebugFormat debugFormat, boolean dryRunCodeSigning, boolean cacheable) throws NoSuchBuildTargetException { AppleCxxPlatform appleCxxPlatform = ApplePlatforms.getAppleCxxPlatformForBuildTarget( cxxPlatformFlavorDomain, defaultCxxPlatform, appleCxxPlatforms, params.getBuildTarget(), MultiarchFileInfos.create(appleCxxPlatforms, params.getBuildTarget())); AppleBundleDestinations destinations; if (extension.isLeft() && extension.getLeft().equals(AppleBundleExtension.FRAMEWORK)) { destinations = AppleBundleDestinations .platformFrameworkDestinations(appleCxxPlatform.getAppleSdk().getApplePlatform()); } else {//from w w w . j a v a2 s. c o m destinations = AppleBundleDestinations .platformDestinations(appleCxxPlatform.getAppleSdk().getApplePlatform()); } AppleBundleResources collectedResources = AppleResources.collectResourceDirsAndFiles(targetGraph, Optional.empty(), targetGraph.get(params.getBuildTarget())); ImmutableSet.Builder<SourcePath> frameworksBuilder = ImmutableSet.builder(); if (INCLUDE_FRAMEWORKS.getRequiredValue(params.getBuildTarget())) { for (BuildTarget dep : deps) { Optional<FrameworkDependencies> frameworkDependencies = resolver.requireMetadata( BuildTarget.builder(dep).addFlavors(FRAMEWORK_FLAVOR) .addFlavors(NO_INCLUDE_FRAMEWORKS_FLAVOR) .addFlavors(appleCxxPlatform.getCxxPlatform().getFlavor()).build(), FrameworkDependencies.class); if (frameworkDependencies.isPresent()) { frameworksBuilder.addAll(frameworkDependencies.get().getSourcePaths()); } } } ImmutableSet<SourcePath> frameworks = frameworksBuilder.build(); SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver); SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder); BuildRuleParams paramsWithoutBundleSpecificFlavors = stripBundleSpecificFlavors(params); Optional<AppleAssetCatalog> assetCatalog = createBuildRuleForTransitiveAssetCatalogDependencies(targetGraph, paramsWithoutBundleSpecificFlavors, sourcePathResolver, appleCxxPlatform.getAppleSdk().getApplePlatform(), appleCxxPlatform.getActool()); Optional<CoreDataModel> coreDataModel = createBuildRulesForCoreDataDependencies(targetGraph, paramsWithoutBundleSpecificFlavors, AppleBundle.getBinaryName(params.getBuildTarget(), productName), appleCxxPlatform); Optional<SceneKitAssets> sceneKitAssets = createBuildRulesForSceneKitAssetsDependencies(targetGraph, paramsWithoutBundleSpecificFlavors, appleCxxPlatform); // TODO(bhamiltoncx): Sort through the changes needed to make project generation work with // binary being optional. BuildRule flavoredBinaryRule = getFlavoredBinaryRule(cxxPlatformFlavorDomain, defaultCxxPlatform, targetGraph, paramsWithoutBundleSpecificFlavors.getBuildTarget().getFlavors(), resolver, binary); if (!AppleDebuggableBinary.isBuildRuleDebuggable(flavoredBinaryRule)) { debugFormat = AppleDebugFormat.NONE; } BuildTarget unstrippedTarget = flavoredBinaryRule.getBuildTarget() .withoutFlavors(CxxStrip.RULE_FLAVOR, AppleDebuggableBinary.RULE_FLAVOR, AppleBinaryDescription.APP_FLAVOR) .withoutFlavors(StripStyle.FLAVOR_DOMAIN.getFlavors()) .withoutFlavors(AppleDebugFormat.FLAVOR_DOMAIN.getFlavors()) .withoutFlavors(AppleDebuggableBinary.RULE_FLAVOR) .withoutFlavors(ImmutableSet.of(AppleBinaryDescription.APP_FLAVOR)); Optional<LinkerMapMode> linkerMapMode = LinkerMapMode.FLAVOR_DOMAIN.getValue(params.getBuildTarget()); if (linkerMapMode.isPresent()) { unstrippedTarget = unstrippedTarget.withAppendedFlavors(linkerMapMode.get().getFlavor()); } BuildRule unstrippedBinaryRule = resolver.requireRule(unstrippedTarget); BuildRule targetDebuggableBinaryRule; Optional<AppleDsym> appleDsym; if (unstrippedBinaryRule instanceof ProvidesLinkedBinaryDeps) { BuildTarget binaryBuildTarget = getBinaryFromBuildRuleWithBinary(flavoredBinaryRule).getBuildTarget() .withoutFlavors(AppleDebugFormat.FLAVOR_DOMAIN.getFlavors()); BuildRuleParams binaryParams = params.copyWithBuildTarget(binaryBuildTarget); targetDebuggableBinaryRule = createAppleDebuggableBinary(binaryParams, resolver, getBinaryFromBuildRuleWithBinary(flavoredBinaryRule), (ProvidesLinkedBinaryDeps) unstrippedBinaryRule, debugFormat, cxxPlatformFlavorDomain, defaultCxxPlatform, appleCxxPlatforms); appleDsym = createAppleDsymForDebugFormat(debugFormat, binaryParams, resolver, (ProvidesLinkedBinaryDeps) unstrippedBinaryRule, cxxPlatformFlavorDomain, defaultCxxPlatform, appleCxxPlatforms); } else { targetDebuggableBinaryRule = unstrippedBinaryRule; appleDsym = Optional.empty(); } BuildRuleParams bundleParamsWithFlavoredBinaryDep = getBundleParamsWithUpdatedDeps(params, binary, ImmutableSet.<BuildRule>builder().add(targetDebuggableBinaryRule) .addAll(OptionalCompat.asSet(assetCatalog)).addAll(OptionalCompat.asSet(coreDataModel)) .addAll(OptionalCompat.asSet(sceneKitAssets)) .addAll(BuildRules.toBuildRulesFor(params.getBuildTarget(), resolver, SourcePaths.filterBuildTargetSourcePaths(Iterables .concat(ImmutableList.of(collectedResources.getAll(), frameworks))))) .addAll(OptionalCompat.asSet(appleDsym)).build()); ImmutableMap<SourcePath, String> extensionBundlePaths = collectFirstLevelAppleDependencyBundles( params.getDeps(), destinations); return new AppleBundle(bundleParamsWithFlavoredBinaryDep, sourcePathResolver, extension, productName, infoPlist, infoPlistSubstitutions, Optional.of(getBinaryFromBuildRuleWithBinary(flavoredBinaryRule)), appleDsym, destinations, collectedResources, extensionBundlePaths, frameworks, appleCxxPlatform, assetCatalog, coreDataModel, sceneKitAssets, tests, codeSignIdentityStore, provisioningProfileStore, dryRunCodeSigning, cacheable); }