List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:org.gradle.jvm.internal.resolve.DefaultVariantsMetaData.java
public static VariantsMetaData extractFrom(BinarySpec binarySpec, ModelSchema<?> binarySpecSchema) { Map<String, Object> variants = Maps.newLinkedHashMap(); ImmutableMap.Builder<String, ModelType<?>> dimensionTypesBuilder = ImmutableMap.builder(); if (binarySpecSchema instanceof StructSchema) { VariantAspect variantAspect = ((StructSchema<?>) binarySpecSchema).getAspect(VariantAspect.class); if (variantAspect != null) { for (ModelProperty<?> property : variantAspect.getDimensions()) { // note: it's not the role of this class to validate that the annotation is properly used, that // is to say only on a getter returning String or a Named instance, so we trust the result of // the call Object value = property.getPropertyValue(binarySpec); variants.put(property.getName(), value); dimensionTypesBuilder.put(property.getName(), property.getType()); }// www. j a v a 2s.com } } return new DefaultVariantsMetaData(Collections.unmodifiableMap(variants), dimensionTypesBuilder.build()); }
From source file:com.bennavetta.vetinari.parse.SiteLoader.java
public Site load(VetinariContext context) throws VetinariException { Site.SiteBuilder siteBuilder = Site.builder(); siteBuilder.siteConfig(context.getSiteConfig()); ImmutableMap.Builder<String, Page> pageBuilder = ImmutableMap.builder(); try {// ww w .j av a 2 s . c om log.info("Loading content pages from {}", context.getContentRoot()); for (Path file : Files.walk(context.getContentRoot()).filter(Files::isRegularFile) .collect(Collectors.toList())) { Page page = pageParser.parsePage(file, context); pageBuilder.put(page.getIdentifier(), page); } } catch (IOException e) { throw new VetinariException("Unable to load content pages", e); } siteBuilder.pages(pageBuilder.build()); return siteBuilder.build(); }
From source file:org.sonar.batch.rule.ModuleQProfiles.java
public ModuleQProfiles(Collection<QualityProfile> profiles) { ImmutableMap.Builder<String, QProfile> builder = ImmutableMap.builder(); for (QualityProfile qProfile : profiles) { builder.put(qProfile.getLanguage(), new QProfile().setKey(qProfile.getKey()).setName(qProfile.getName()) .setLanguage(qProfile.getLanguage()) .setRulesUpdatedAt(DateUtils.parseDateTime(qProfile.getRulesUpdatedAt()))); }/*from ww w . j a v a2s. c o m*/ byLanguage = builder.build(); }
From source file:io.pravega.client.stream.impl.CheckpointImpl.java
CheckpointImpl(String name, Map<Segment, Long> segmentPositions) { this.name = name; Map<Stream, ImmutableMap.Builder<Segment, Long>> streamPositions = new HashMap<>(); for (Entry<Segment, Long> position : segmentPositions.entrySet()) { streamPositions/*from w w w .j ava 2 s .c om*/ .computeIfAbsent(position.getKey().getStream(), k -> new ImmutableMap.Builder<Segment, Long>()) .put(position); } ImmutableMap.Builder<Stream, StreamCut> positionBuilder = ImmutableMap.builder(); for (Entry<Stream, Builder<Segment, Long>> streamPosition : streamPositions.entrySet()) { positionBuilder.put(streamPosition.getKey(), new StreamCut(streamPosition.getKey(), streamPosition.getValue().build())); } this.positions = positionBuilder.build(); }
From source file:com.spotify.statistics.MergingMuninGraphProvider.java
@Override public Map<String, MuninGraph> getGraphs() { final ImmutableMap.Builder<String, MuninGraph> builder = ImmutableMap.builder(); for (final MuninGraphProvider provider : providers) { builder.putAll(provider.getGraphs()); }//from w ww. j av a 2s. co m return builder.build(); }
From source file:com.isotrol.impe3.core.support.FileLoaderSupport.java
/** * Loads a file item contained in an zip-codified input stream. * @param stream Input stream./*w w w .ja v a2 s. com*/ * @param name The contained file name. * @return The file data or {@code null} if the file is not found. * @throws NullPointerException If any of the arguments is null. * @throws IOException If an error occurs. */ public static FileBundleData loadBundle(final FileData file) throws IOException { checkNotNull(file); final UUID id = file.getId(); final String name = file.getName(); checkArgument(file.isBundle(), "File [%s] with id [%s] is not a bundle", id, name); ImmutableMap.Builder<String, FileData> b = ImmutableMap.builder(); final ZipInputStream zis = new ZipInputStream(file.getData()); try { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { final byte[] data = Streams.consume(zis, false); final String item = entry.getName(); b.put(item, FileData.item(file, item, getMediaType(item), data, false)); zis.closeEntry(); } } finally { zis.close(); } return FileBundleData.create(file, b.build()); }
From source file:org.gradle.internal.component.external.model.DefaultMutableIvyModuleResolveMetadata.java
private static Map<String, Configuration> toMap(Collection<Configuration> configurations) { ImmutableMap.Builder<String, Configuration> builder = ImmutableMap.builder(); for (Configuration configuration : configurations) { builder.put(configuration.getName(), configuration); }//from w w w . ja v a2 s . c o m return builder.build(); }
From source file:com.haulmont.bali.util.ParamsMap.java
public static Map<String, Object> of(String paramName1, Object paramValue1, String paramName2, Object paramValue2, String paramName3, Object paramValue3, String paramName4, Object paramValue4) { ImmutableMap.Builder<String, Object> b = new ImmutableMap.Builder<>(); put(b, paramName1, paramValue1);// w w w .ja v a2s.c o m put(b, paramName2, paramValue2); put(b, paramName3, paramValue3); put(b, paramName4, paramValue4); return b.build(); }
From source file:ch.ledcom.jpreseed.distro.Distribution.java
public Distribution(String name, List<DistroVersion> versions) { this.name = checkNotNull(name, "Distribution name cannot be null"); ImmutableMap.Builder<String, DistroVersion> byNameBuilder = ImmutableMap.builder(); ImmutableMap.Builder<String, DistroVersion> byShortNameBuilder = ImmutableMap.builder(); ImmutableMap.Builder<String, DistroVersion> byNumberBuilder = ImmutableMap.builder(); for (DistroVersion version : versions) { byNameBuilder.put(version.getName(), version); byShortNameBuilder.put(version.getShortName(), version); byNumberBuilder.put(version.getNumber(), version); }//from ww w .j a v a 2s. c om this.versions = ImmutableList.copyOf(versions); this.versionsByName = byNameBuilder.build(); this.versionsByShortName = byShortNameBuilder.build(); this.versionsByNumber = byNumberBuilder.build(); }
From source file:com.facebook.buck.apple.project_generator.CxxPlatformXcodeConfigGenerator.java
public static ImmutableMap<String, ImmutableMap<String, String>> getDefaultXcodeBuildConfigurationsFromCxxPlatform( CxxPlatform cxxPlatform, Map<String, String> appendedConfig) { ArrayList<String> notProcessedCxxFlags = new ArrayList<String>(cxxPlatform.getCxxflags()); LinkedHashMap<String, String> notProcessedAppendedConfig = new LinkedHashMap<String, String>( appendedConfig);/*from ww w.j ava 2s . c om*/ ImmutableMap.Builder<String, String> configBuilder = ImmutableMap.builder(); setSdkRootAndDeploymentTargetValues(configBuilder, cxxPlatform, notProcessedCxxFlags, notProcessedAppendedConfig); removeArchsValue(notProcessedCxxFlags, notProcessedAppendedConfig); setLanguageStandardValue(configBuilder, notProcessedCxxFlags, notProcessedAppendedConfig); setCxxLibraryValue(notProcessedCxxFlags, notProcessedAppendedConfig, configBuilder); setOtherCplusplusFlagsValue(configBuilder, notProcessedCxxFlags, notProcessedAppendedConfig); setFlagsFromNotProcessedAppendedConfig(configBuilder, notProcessedAppendedConfig); ImmutableMap<String, String> config = configBuilder.build(); return new ImmutableMap.Builder<String, ImmutableMap<String, String>>() .put(DEBUG_BUILD_CONFIGURATION_NAME, config).put(PROFILE_BUILD_CONFIGURATION_NAME, config) .put(RELEASE_BUILD_CONFIGURATION_NAME, config).build(); }