List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:com.google.api.codegen.ruby.RubyApiaryNameMap.java
@SuppressWarnings("unchecked") private static ImmutableMap<ResourceId, String> getNameMap() throws IOException { String data = Resources.toString(Resources.getResource(RubyApiaryNameMap.class, "apiary_names.yaml"), StandardCharsets.UTF_8); // Unchecked cast here. Map<String, String> nameData = (Map<String, String>) (new Yaml().load(data)); ImmutableMap.Builder<ResourceId, String> builder = ImmutableMap.<ResourceId, String>builder(); for (Map.Entry<String, String> entry : nameData.entrySet()) { builder.put(parseKey(entry.getKey()), entry.getValue()); }//w w w. j a va 2 s . c o m return builder.build(); }
From source file:org.jclouds.elasticstack.functions.DriveDataToMap.java
@Override public Map<String, String> apply(DriveData from) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); builder.putAll(baseDriveToMap.apply(from)); return builder.build(); }
From source file:com.jgaap.backend.EventCullers.java
private static ImmutableMap<String, EventCuller> loadEventCullersMap() { // Load the classifiers dynamically ImmutableMap.Builder<String, EventCuller> builder = ImmutableMap.builder(); for (EventCuller eventCuller : EVENT_CULLERS) { builder.put(eventCuller.displayName().toLowerCase().trim(), eventCuller); }//from www .ja va 2 s . c o m return builder.build(); }
From source file:com.facebook.buck.parser.TargetNodePredicateSpec.java
@Override public ImmutableMap<BuildTarget, TargetNode<?>> filter(Iterable<TargetNode<?>> nodes) { ImmutableMap.Builder<BuildTarget, TargetNode<?>> resultBuilder = ImmutableMap.builder(); for (TargetNode<?> node : nodes) { if (!onlyTests() || node.getRuleType().isTestRule()) { resultBuilder.put(node.getBuildTarget(), node); }/*w ww . ja v a2 s .c o m*/ } return resultBuilder.build(); }
From source file:com.codingopus.guava.custom.collectors.BaseImmutableMapCollector.java
@Override public Function<Builder<K, V>, ImmutableMap<K, V>> finisher() { return ImmutableMap.Builder<K, V>::build; }
From source file:no.ssb.vtl.script.functions.TypeSafeArguments.java
public TypeSafeArguments(Map<String, VTLObject> arguments, Map<String, AbstractVTLFunction.Argument<?>> signature) { checkArgument(arguments.size() == signature.size()); ImmutableMap.Builder<AbstractVTLFunction.Argument, VTLObject<?>> builder = ImmutableMap.builder(); for (String name : signature.keySet()) { VTLObject value = arguments.get(name); AbstractVTLFunction.Argument argument = signature.get(name); builder.put(argument, checkType(value, argument)); }// w w w.ja va 2 s.co m this.arguments = builder.build(); }
From source file:com.facebook.buck.apple.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);/* w w w.j a v a 2 s. c o m*/ ImmutableMap.Builder<String, String> configBuilder = ImmutableMap.<String, String>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(); }
From source file:garmintools.adapters.garmin.LandingFacilityIdentifierIndexGarminAdapter.java
@Override public Map<Byte, Integer> read(DataLengthSection dataLengthSection, TableOfContentsEntry entry, ByteBuffer byteBuffer) {/* w ww. jav a 2s . c o m*/ Preconditions.checkState(entry.itemQuantity == NUM_ENTRIES); ImmutableMap.Builder<Byte, Integer> mapBuilder = ImmutableMap.builder(); Preconditions.checkState(entry.itemLength == 3); for (int i = 0; i < entry.itemQuantity; ++i) { int offset = byteBuffer.getShort() & 0xffff; offset |= (byteBuffer.get() << 16); byte landingFacilityIdentifierPrefixByte = (byte) (i + 4); if (landingFacilityIdentifierPrefixByte <= NUM_ENTRIES && offset != NOT_PRESENT_INDEX_MARKER) { mapBuilder.put(landingFacilityIdentifierPrefixByte, offset); } } return mapBuilder.build(); }
From source file:io.airlift.event.client.JsonEventWriter.java
@Inject public JsonEventWriter(Set<EventTypeMetadata<?>> eventTypes) { Preconditions.checkNotNull(eventTypes, "eventTypes is null"); this.jsonFactory = new JsonFactory(); ImmutableMap.Builder<Class<?>, JsonSerializer<?>> serializerBuilder = ImmutableMap.builder(); for (EventTypeMetadata<?> eventType : eventTypes) { serializerBuilder.put(eventType.getEventClass(), new EventJsonSerializer<>(eventType)); }// w w w . j av a2 s .co m this.serializers = serializerBuilder.build(); }
From source file:ru.org.linux.section.SectionDao.java
@Autowired public SectionDao(DataSource ds) { jdbcTemplate = new JdbcTemplate(ds); final ImmutableMap.Builder<Integer, Section> sections = ImmutableMap.builder(); final ImmutableList.Builder<Section> sectionsList = ImmutableList.builder(); jdbcTemplate.query("SELECT id, name, imagepost, vote, moderate FROM sections ORDER BY id", new RowCallbackHandler() { @Override/*from ww w.jav a 2 s. c om*/ public void processRow(ResultSet rs) throws SQLException { Section section = new Section(rs); sections.put(section.getId(), section); sectionsList.add(section); } }); this.sections = sections.build(); this.sectionsList = sectionsList.build(); }