Example usage for com.google.common.collect ImmutableBiMap entrySet

List of usage examples for com.google.common.collect ImmutableBiMap entrySet

Introduction

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

Prototype

Set<Map.Entry<K, V>> entrySet();

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:com.google.caliper.config.CaliperConfig.java

private static ImmutableMap<Class<? extends ResultProcessor>, ResultProcessorConfig> findResultProcessorConfigs(
        ImmutableMap<String, String> resultsProperties) throws InvalidConfigurationException {
    ImmutableBiMap<String, Class<? extends ResultProcessor>> processorToClass = mapGroupNamesToClasses(
            resultsProperties, ResultProcessor.class);
    ImmutableMap.Builder<Class<? extends ResultProcessor>, ResultProcessorConfig> builder = ImmutableMap
            .builder();//from w w w.  j  a v a  2s .co  m
    for (Entry<String, Class<? extends ResultProcessor>> entry : processorToClass.entrySet()) {
        builder.put(entry.getValue(), getResultProcessorConfig(resultsProperties, entry.getKey()));
    }
    return builder.build();
}

From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.design.system.model.NormalizedNamingAuthority.java

@Override
public void tryReplace(final Map<? extends String, ? extends String> oldToNew) {
    Preconditions.checkNotNull(oldToNew);

    final ImmutableBiMap<String, String> copy = ImmutableBiMap.copyOf(oldToNew);

    for (final Map.Entry<String, String> replacementPair : copy.entrySet()) {
        final String oldName = replacementPair.getKey();
        final String newName = replacementPair.getValue();

        Preconditions.checkArgument(isUsed(oldName), ExceptionLocalizer.print("NameNotUsed", oldName));
        Preconditions.checkArgument(oldName.equals(newName) || isUsable(newName),
                ExceptionLocalizer.print("NameNotUsable", newName));
    }/*from  w  w  w .j ava 2s .  co m*/

    final Set<String> oldNames = copy.keySet();
    final Set<String> newNames = copy.values();
    for (final String oldName : oldNames) {
        this.used.remove(oldName);
    }

    for (final String newName : newNames) {
        this.used.add(newName);
    }
}

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)./*from w  ww  .ja va 2 s.co  m*/
    pathsBuilder.put(realCompilationDirectory, fakeCompilationDirectory);
    for (Path p : other.keySet()) {
        Assertions.assertCondition(!realCompilationDirectory.toString().contains(p.toString()));
    }

    this.allPaths = pathsBuilder.build();
}