Example usage for com.google.common.collect ImmutableBiMap.Builder putAll

List of usage examples for com.google.common.collect ImmutableBiMap.Builder putAll

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableBiMap.Builder putAll.

Prototype

@Override
void putAll(Map<? extends K, ? extends V> map);

Source Link

Document

Warning: the results of calling this method may vary depending on the iteration order of map .

Usage

From source file:com.publictransitanalytics.scoregenerator.workflow.Calculation.java

private static BiMap<String, PointLocation> buildPointIdMap(final Set<PointLocation> centerPoints,
        final BiMap<String, TransitStop> transitStops, final Grid grid) {
    final ImmutableBiMap.Builder<String, PointLocation> pointMapBuilder = ImmutableBiMap.builder();
    pointMapBuilder.putAll(transitStops);

    for (final PointLocation centerPoint : centerPoints) {
        pointMapBuilder.put(centerPoint.getIdentifier(), centerPoint);
    }//  w w w.  java  2s  .co  m

    final Set<? extends PointLocation> gridPoints = Sets.difference(grid.getGridPoints(), centerPoints);
    for (final PointLocation gridPoint : gridPoints) {
        pointMapBuilder.put(gridPoint.getIdentifier(), gridPoint);
    }
    final BiMap<String, PointLocation> pointIdMap = pointMapBuilder.build();
    return pointIdMap;
}

From source file:com.facebook.buck.cxx.MungingDebugPathSanitizer.java

private ImmutableBiMap<Path, Path> getAllPathsWork(Path workingDir) {
    ImmutableBiMap.Builder<Path, Path> builder = ImmutableBiMap.builder();
    builder.put(workingDir, compilationDirectory);
    builder.putAll(other);
    return builder.build();
}

From source file:uk.submergedcode.SubmergedCore.serialization.AchievementSerializer.java

public AchievementSerializer() {
    ImmutableMap<String, Achievement> specialCases = ImmutableMap.<String, Achievement>builder()
            .put("achievement.buildWorkBench", Achievement.BUILD_WORKBENCH)
            .put("achievement.diamonds", Achievement.GET_DIAMONDS)
            .put("achievement.portal", Achievement.NETHER_PORTAL)
            .put("achievement.ghast", Achievement.GHAST_RETURN)
            .put("achievement.theEnd", Achievement.END_PORTAL).put("achievement.theEnd2", Achievement.THE_END)
            .put("achievement.blazeRod", Achievement.GET_BLAZE_ROD)
            .put("achievement.potion", Achievement.BREW_POTION).build();

    ImmutableBiMap.Builder<String, Achievement> builder = ImmutableBiMap.<String, Achievement>builder();
    for (Achievement achievement : Achievement.values()) {
        if (specialCases.values().contains(achievement)) {
            continue;
        }/*from www  .  j ava  2s  .  c o m*/
        builder.put("achievement." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()),
                achievement);
    }

    builder.putAll(specialCases);

    achievements = builder.build();
}

From source file:com.facebook.buck.cxx.PrefixMapDebugPathSanitizer.java

public PrefixMapDebugPathSanitizer(int pathSize, char separator, Path fakeCompilationDirectory,
        ImmutableBiMap<Path, Path> other, Path realCompilationDirectory, CxxToolProvider.Type cxxType) {
    super(separator, pathSize, fakeCompilationDirectory);
    this.isGcc = cxxType == CxxToolProvider.Type.GCC;
    this.compilationDir = realCompilationDirectory;
    ImmutableBiMap.Builder<Path, Path> pathsBuilder = ImmutableBiMap.builder();
    // As these replacements are processed one at a time, if one is a prefix (or actually is just
    // contained in) another, it must be processed after that other one. To ensure that we can
    // process them in the correct order, they are inserted into allPaths in order of length
    // (longest first). Then, if they are processed in the order in allPaths, prefixes will be
    // handled correctly.
    pathsBuilder.putAll(FluentIterable.from(other.entrySet()).toSortedList(
            (left, right) -> right.getKey().toString().length() - left.getKey().toString().length()));
    // We assume that nothing in other is a prefix of realCompilationDirectory (though the reverse
    // is fine)./*  www.java  2  s  .  com*/
    pathsBuilder.put(realCompilationDirectory, fakeCompilationDirectory);
    for (Path p : other.keySet()) {
        Assertions.assertCondition(!realCompilationDirectory.toString().contains(p.toString()));
    }

    this.allPaths = pathsBuilder.build();
}