List of usage examples for com.google.common.collect ImmutableMap.Builder putAll
public final void putAll(Map<? extends K, ? extends V> map)
From source file:org.apache.beam.runners.core.construction.PTransformTranslation.java
private static Map<Class<? extends PTransform>, TransformPayloadTranslator> loadTransformPayloadTranslators() { ImmutableMap.Builder<Class<? extends PTransform>, TransformPayloadTranslator> builder = ImmutableMap .builder();//from w w w . ja v a 2 s. c o m for (TransformPayloadTranslatorRegistrar registrar : ServiceLoader .load(TransformPayloadTranslatorRegistrar.class)) { builder.putAll(registrar.getTransformPayloadTranslators()); } return builder.build(); }
From source file:com.opengamma.strata.examples.marketdata.curve.RatesCurvesCsvLoader.java
private static ImmutableSortedMap<LocalDate, Map<RateCurveId, Curve>> loadCurvesForDate( ResourceLocator groupsResource, ResourceLocator settingsResource, Collection<ResourceLocator> curvesResources, LocalDate curveDate) { // load curves Map<LoadedCurveName, LoadedCurveSettings> settingsMap = loadCurveSettings(settingsResource); ImmutableMap.Builder<LoadedCurveKey, Curve> curvesBuilder = new ImmutableMap.Builder<>(); for (ResourceLocator curvesResource : curvesResources) { // builder ensures keys can only be seen once curvesBuilder.putAll(loadCurvesFile(curvesResource, settingsMap, curveDate)); }/*from w ww .ja v a2 s.c om*/ ImmutableMap<LoadedCurveKey, Curve> curves = curvesBuilder.build(); // load curve groups Map<LoadedCurveName, Set<RateCurveId>> curveGroups = loadCurveGroups(groupsResource); return mapCurves(curveGroups, curves); }
From source file:org.mule.module.extension.internal.capability.xml.schema.AnnotationProcessorUtils.java
/** * Scans all classes in the {@code roundEnvironment} looking * for methods annotated with {@link Operation}. * * @param roundEnvironment the current {@link RoundEnvironment} * @return a {@link Map} which keys are the method names and the values are the * method represented as a {@link ExecutableElement} */// w ww . jav a 2s.co m static Map<String, ExecutableElement> getOperationMethods(RoundEnvironment roundEnvironment) { ImmutableMap.Builder<String, ExecutableElement> methods = ImmutableMap.builder(); for (Element rootElement : roundEnvironment.getRootElements()) { if (!(rootElement instanceof TypeElement)) { continue; } methods.putAll(getMethodsAnnotatedWith((TypeElement) rootElement, Operation.class)); } return methods.build(); }
From source file:com.facebook.buck.jvm.java.JavaLibraryRules.java
/** * @return all the transitive native libraries a rule depends on, represented as * a map from their system-specific library names to their {@link SourcePath} objects. *//*from w ww. j a v a 2 s . c om*/ public static ImmutableMap<String, SourcePath> getNativeLibraries(Iterable<BuildRule> deps, final CxxPlatform cxxPlatform) throws NoSuchBuildTargetException { final ImmutableMap.Builder<String, SourcePath> libraries = ImmutableMap.builder(); new AbstractBreadthFirstThrowingTraversal<BuildRule, NoSuchBuildTargetException>(deps) { @Override public ImmutableSet<BuildRule> visit(BuildRule rule) throws NoSuchBuildTargetException { if (rule instanceof NativeLinkable) { NativeLinkable linkable = (NativeLinkable) rule; libraries.putAll(linkable.getSharedLibraries(cxxPlatform)); } if (rule instanceof NativeLinkable || rule instanceof JavaLibrary) { return rule.getDeps(); } else { return ImmutableSet.of(); } } }.start(); return libraries.build(); }
From source file:com.google.api.codegen.config.GapicProductConfig.java
private static ImmutableMap<String, ResourceNameConfig> createResourceNameConfigs(DiagCollector diagCollector, ConfigProto configProto, ProtoFile file, TargetLanguage language) { ImmutableMap<String, SingleResourceNameConfig> singleResourceNameConfigs = createSingleResourceNameConfigs( diagCollector, configProto, file, language); ImmutableMap<String, FixedResourceNameConfig> fixedResourceNameConfigs = createFixedResourceNameConfigs( diagCollector, configProto.getFixedResourceNameValuesList(), file); ImmutableMap<String, ResourceNameOneofConfig> resourceNameOneofConfigs = createResourceNameOneofConfigs( diagCollector, configProto.getCollectionOneofsList(), singleResourceNameConfigs, fixedResourceNameConfigs, file); ImmutableMap.Builder<String, ResourceNameConfig> resourceCollectionMap = ImmutableMap.builder(); resourceCollectionMap.putAll(singleResourceNameConfigs); resourceCollectionMap.putAll(resourceNameOneofConfigs); resourceCollectionMap.putAll(fixedResourceNameConfigs); return resourceCollectionMap.build(); }
From source file:org.apache.bookkeeper.mledger.offload.jcloud.impl.BlobStoreManagedLedgerOffloader.java
private static void addVersionInfo(BlobBuilder blobBuilder, Map<String, String> userMetadata) { ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder(); metadataBuilder.putAll(userMetadata); metadataBuilder.put(METADATA_FORMAT_VERSION_KEY.toLowerCase(), CURRENT_VERSION); blobBuilder.userMetadata(metadataBuilder.build()); }
From source file:at.ac.univie.isc.asio.web.HttpServer.java
/** * Attempt to parse request parameters from the query string and the request body in case of a * form submission./*from ww w .j ava 2 s . c o m*/ * * @param exchange http exchange * @return parsed parameters as map * @throws IOException on any errors */ public static Map<String, String> parseParameters(final HttpExchange exchange) throws IOException { final ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); final String rawQuery = exchange.getRequestURI().getQuery(); if (rawQuery != null) { // null if no query string present final String query = URLDecoder.decode(rawQuery, StandardCharsets.UTF_8.name()); params.putAll(PARAMETER_PARSER.split(query)); } if (isForm(exchange)) { final String rawBody = Payload.decodeUtf8(ByteStreams.toByteArray(exchange.getRequestBody())); final String form = URLDecoder.decode(rawBody, StandardCharsets.UTF_8.name()); params.putAll(PARAMETER_PARSER.split(form)); } return params.build(); }
From source file:org.opendaylight.yangtools.yang.binding.util.DataObjectReadingUtil.java
/** * * @param parent// w w w . j av a 2s . c om * Parent object on which read operation will be performed * @param parentPath * Path, to parent object. * @param childPath * Path, which is nested to parent, and should be readed. * @return Value of object. */ public static final <T extends DataObject, P extends DataObject> Map<InstanceIdentifier<T>, T> readData( final P parent, final InstanceIdentifier<P> parentPath, final InstanceIdentifier<T> childPath) { checkArgument(parent != null, "Parent must not be null."); checkArgument(parentPath != null, "Parent path must not be null"); checkArgument(childPath != null, "Child path must not be null"); checkArgument(parentPath.containsWildcarded(childPath), "Parent object must be parent of child."); List<PathArgument> pathArgs = subList(parentPath.getPathArguments(), childPath.getPathArguments()); @SuppressWarnings("rawtypes") Map<InstanceIdentifier, DataContainer> lastFound = Collections .<InstanceIdentifier, DataContainer>singletonMap(parentPath, parent); for (PathArgument pathArgument : pathArgs) { @SuppressWarnings("rawtypes") final ImmutableMap.Builder<InstanceIdentifier, DataContainer> potentialBuilder = ImmutableMap.builder(); for (@SuppressWarnings("rawtypes") Entry<InstanceIdentifier, DataContainer> entry : lastFound.entrySet()) { potentialBuilder.putAll(readData(entry, pathArgument)); } lastFound = potentialBuilder.build(); if (lastFound.isEmpty()) { return Collections.emptyMap(); } } @SuppressWarnings({ "unchecked", "rawtypes" }) final Map<InstanceIdentifier<T>, T> result = (Map) lastFound; return result; }
From source file:edu.cmu.lti.oaqa.baseqa.learning_base.Scorer.java
static void generateSummaryDistanceFeatures(double[] distances, ImmutableMap.Builder<String, Double> builder, double infinity, double smoothing, String keyword, String... operators) { // double[] avgPrecedingNegdistances = Arrays.stream(distances) // .map(distance -> distance - infinity).toArray(); // builder.putAll(generateSummaryFeatures(avgPrecedingNegdistances, keyword + "-negdistance", // operators)); double[] avgPrecedingProximities = Arrays.stream(distances).map(distance -> 1.0 / (smoothing + distance)) .toArray();//from w w w . j ava2 s . c o m builder.putAll(generateSummaryFeatures(avgPrecedingProximities, keyword + "-proximity", operators)); }
From source file:io.prestosql.event.QueryMonitor.java
private static void reconstructStatsAndCosts(StageInfo stage, ImmutableMap.Builder<PlanNodeId, PlanNodeStatsEstimate> planNodeStats, ImmutableMap.Builder<PlanNodeId, PlanNodeCostEstimate> planNodeCosts) { PlanFragment planFragment = stage.getPlan(); if (planFragment != null) { planNodeStats.putAll(planFragment.getStatsAndCosts().getStats()); planNodeCosts.putAll(planFragment.getStatsAndCosts().getCosts()); }/*w w w . j av a 2 s .co m*/ for (StageInfo subStage : stage.getSubStages()) { reconstructStatsAndCosts(subStage, planNodeStats, planNodeCosts); } }