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

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

Introduction

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

Prototype

public final ImmutableSet<Entry<K, V>> entrySet() 

Source Link

Usage

From source file:org.jclouds.sqs.options.CreateQueueOptions.java

@Override
public Multimap<String, String> buildFormParameters() {
    Multimap<String, String> params = super.buildFormParameters();
    ImmutableMap<String, String> attributes = this.attributes.build();
    if (attributes.size() > 0) {
        int nameIndex = 1;
        for (Entry<String, String> attribute : attributes.entrySet()) {
            params.put("Attribute." + nameIndex + ".Name", attribute.getKey());
            params.put("Attribute." + nameIndex + ".Value", attribute.getValue());
            nameIndex++;/*from w  w  w.  ja  va2  s .  co m*/
        }
    }
    return params;
}

From source file:com.afewmoreamps.util.COWMap.java

@Override
public V put(K key, V value) {
    while (true) {
        ImmutableMap<K, V> original = m_map.get();
        Builder<K, V> builder = new Builder<K, V>();
        V oldValue = null;/*from   w  w  w  . ja  va 2s  .c o  m*/
        boolean replaced = false;
        for (Map.Entry<K, V> entry : original.entrySet()) {
            if (entry.getKey().equals(key)) {
                oldValue = entry.getValue();
                builder.put(key, value);
                replaced = true;
            } else {
                builder.put(entry);
            }
        }
        if (!replaced) {
            builder.put(key, value);
        }
        ImmutableMap<K, V> copy = builder.build();
        if (m_map.compareAndSet(original, copy)) {
            return oldValue;
        }
    }
}

From source file:com.clearclouds.driver.monitor.jvm.DeadlockAnalyzer.java

private Set<LinkedHashSet<ThreadInfo>> calculateCycles(ImmutableMap<Long, ThreadInfo> threadInfoMap) {
    Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
    for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
        LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
        for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap
                .get(Long.valueOf(t.getLockOwnerId())))
            cycle.add(t);//from  ww w .ja v a 2  s. c o  m

        if (!cycles.contains(cycle))
            cycles.add(cycle);
    }
    return cycles;
}

From source file:org.ow2.proactive.workflow_catalog.rest.service.WorkflowRevisionService.java

protected List<GenericInformation> createEntityGenericInformation(
        ImmutableMap<String, String> genericInformation) {
    return genericInformation.entrySet().stream()
            .map(entry -> new GenericInformation(entry.getKey(), entry.getValue()))
            .collect(Collectors.toList());
}

From source file:com.palantir.atlasdb.transaction.impl.AbstractTransaction.java

private void pushWritesToKvService(String tableName, AtomicLong inMemSize,
        ConcurrentNavigableMap<Cell, byte[]> writes) {
    long removedSize = 0;
    ImmutableMap<Cell, byte[]> toWrite = ImmutableMap.copyOf(writes);
    getKeyValueService().put(tableName, toWrite, getNewBatchNumber(tableName));
    for (Map.Entry<Cell, byte[]> e : toWrite.entrySet()) {
        if (writes.remove(e.getKey(), e.getValue())) {
            removedSize += e.getValue().length + Cells.getApproxSizeOfCell(e.getKey());
        }//from   w w w .  j av a  2  s .com
    }
    inMemSize.addAndGet(-removedSize);
}

From source file:org.grycap.gpf4med.rest.Gpf4MedApplication.java

public Gpf4MedApplication() {
    // load configuration
    ConfigurationManager.INSTANCE.getRootDir();
    // create a proxy to the Gpf4Med JAX-RS resource implementation      
    final Gpf4MedResource gpf4medProxy = newGpf4MedResourceProxy(executorService);
    instances.add(gpf4medProxy);/*from   w w w .j ava 2  s .  c  o m*/
    // scan for connectors and create proxies to their JAX-RS resources
    final ImmutableMap<String, GraphConnector> connectors = GraphConnectorManager.INSTANCE.listConnectors();
    if (connectors != null && !connectors.isEmpty()) {
        instances.addAll(
                transform(connectors.entrySet(), new Function<Map.Entry<String, GraphConnector>, Object>() {
                    @Override
                    public Object apply(final Entry<String, GraphConnector> entry) {
                        final Class<?> type = entry.getValue().restResourceDefinition();
                        return newResourceProxy(type, executorService);
                    }
                }));
    }
    // start service
    final Gpf4MedEnactor service = SingletonService.INSTANCE.service();
    // register shutdown hook
    shutdownHook.register(service);
    LOGGER.info(SERVICE_NAME + " initialized successfully, registered resources: "
            + Arrays.toString(instances.toArray()));
}

From source file:com.edmunds.zookeeper.treewatcher.ZooKeeperTreeDelta.java

private void walkChildren(ImmutableMap<String, ZooKeeperTreeNode> oldChildren,
        ImmutableMap<String, ZooKeeperTreeNode> newChildren, ZooKeeperTreeDeltaResult result) {

    for (Map.Entry<String, ZooKeeperTreeNode> entry : newChildren.entrySet()) {
        final ZooKeeperTreeNode oldValue = oldChildren.get(entry.getKey());
        if (oldValue != null) {
            walkTree(oldValue, entry.getValue(), result);
        }//from  w w w  .  jav a  2  s .  com
    }
}

From source file:dollar.plugins.pipe.GithubModuleResolver.java

@NotNull
@Override//from   ww w . ja va  2s . co  m
public <T, P> Pipeable retrieveModule(@NotNull String uriWithoutScheme, @NotNull T scope, @NotNull P parser)
        throws Exception {
    log.debug(uriWithoutScheme);
    File dir = repos.get(uriWithoutScheme);

    String[] githubRepo = uriWithoutScheme.split(":");

    final ClassLoader classLoader;
    final String content;
    final File mainFile;

    if (githubRepo.length == 4) {

        classLoader = getClass().getClassLoader();
        mainFile = new File(dir, githubRepo[3]);
        content = new String(Files.readAllBytes(mainFile.toPath()));

    } else {

        final File moduleFile = new File(dir, "module.json");
        final Value module = DollarStatic.$(new String(Files.readAllBytes(moduleFile.toPath())));
        mainFile = new File(dir, module.$get(DollarStatic.$("main")).$S());
        content = new String(Files.readAllBytes(mainFile.toPath()));
        classLoader = DependencyRetriever.retrieve(module.$get(DollarStatic.$("dependencies")).$list()
                .stream(false).map(t -> module.toString()).collect(Collectors.toList()));

    }
    return (params) -> util().inSubScope(false, false, "github-module", newScope -> {

        final ImmutableMap<Value, Value> paramMap = params[0].$map().toVarMap();
        for (Map.Entry<Value, Value> entry : paramMap.entrySet()) {
            newScope.set(VarKey.of(entry.getKey()), entry.getValue(), null, null,
                    new VarFlags(true, false, false, false, false, false));
        }
        return new DollarParserImpl(((DollarParser) parser).options(), classLoader)
                .parse(new FileScope((Scope) scope, mainFile.getAbsolutePath(), content, "github-module-scope",
                        false, false), content);
    }).orElseThrow(() -> new AssertionError("Optional should not be null here"));
}

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

private ImmutableList<String> getObjcopyCommand(ImmutableMap<String, Long> addresses) {
    ImmutableList.Builder<String> args = ImmutableList.builder();
    args.addAll(getObjcopyPrefix());//from   w  w  w  .  j a va2 s  .c o  m
    args.add("--no-change-warnings");
    for (Map.Entry<String, Long> ent : addresses.entrySet()) {
        String section = ent.getKey();
        long address = ent.getValue();
        args.add("--change-section-address", String.format("%s=0x%x", section, address));
    }
    args.add(getInputFilesystem().resolve(getInput()).toString());
    args.add(getOutputFilesystem().resolve(getOutput()).toString());
    return args.build();
}

From source file:com.facebook.buck.rules.modern.impl.StringifyingValueVisitor.java

private <K, V> void visitMapValues(ImmutableMap<K, V> value, ValueTypeInfo<K> keyType,
        ValueTypeInfo<V> valueType) {
    for (Map.Entry<K, V> e : value.entrySet()) {
        newline();/*from   w  w  w  .j  a  va2s . c o m*/
        container("key", () -> {
            newline();
            keyType.visit(e.getKey(), this);
        });
        newline();
        container("value", () -> {
            newline();
            valueType.visit(e.getValue(), this);
        });
    }
}