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:com.github.gv2011.util.icol.guava.AbstractIMapBuilder.java

@Override
public B putAll(final Collection<? extends Entry<? extends K, ? extends V>> map) {
    final ImmutableMap<K, V> copy = ImmutableMap.copyOf(map);
    synchronized (this.map) {
        verify(copy.entrySet().stream().allMatch(
                e -> e.getKey() != null && e.getValue() != null && !this.map.containsKey(e.getKey())));
        this.map.putAll(copy);
    }/*from   www. j  a  v a 2 s . co  m*/
    return self();
}

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

/**
 * Resolve the map of names to SourcePaths to a map of names to CxxSource objects.
 *//* w  w  w .j  a  v  a 2 s.  co m*/
private static ImmutableMap<String, CxxSource> resolveCxxSources(
        ImmutableMap<String, SourceWithFlags> sources) {

    ImmutableMap.Builder<String, CxxSource> cxxSources = ImmutableMap.builder();

    // For each entry in the input C/C++ source, build a CxxSource object to wrap
    // it's name, input path, and output object file path.
    for (ImmutableMap.Entry<String, SourceWithFlags> ent : sources.entrySet()) {
        String extension = Files.getFileExtension(ent.getKey());
        Optional<CxxSource.Type> type = CxxSource.Type.fromExtension(extension);
        if (!type.isPresent()) {
            throw new HumanReadableException("invalid extension \"%s\": %s", extension, ent.getKey());
        }
        cxxSources.put(ent.getKey(),
                CxxSource.of(type.get(), ent.getValue().getSourcePath(), ent.getValue().getFlags()));
    }

    return cxxSources.build();
}

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

public ByteBufferReplacer(ImmutableMap<byte[], byte[]> replacements) {
    for (Map.Entry<byte[], byte[]> entry : replacements.entrySet()) {
        Preconditions.checkArgument(entry.getKey().length == entry.getValue().length);
    }/*  ww w . j ava2s  .co m*/
    this.replacements = replacements;
}

From source file:io.fabric8.jube.proxy.KubeProxy.java

protected synchronized void serviceChanged(String id, Service serviceEntity) {
    if (ignoredServiceIDs.contains(id)) {
        return;/*from   www  .jav  a  2s  . c o  m*/
    }

    // lets delete the old service as we may have changed the port or selector
    serviceDeleted(id);

    ServiceInstance service = new ServiceInstance(serviceEntity);
    int port = service.getPort();
    LoadBalancer loadBalancer = service.getLoadBalancer();
    ServiceProxy serviceProxy = new ServiceProxy(vertx, service, port, loadBalancer);
    serviceProxy.init();
    serviceMap.put(id, serviceProxy);

    // now lets populate it with the current pods
    ImmutableMap<String, Pod> podMap = model.getPodMap();
    ImmutableSet<Map.Entry<String, Pod>> entries = podMap.entrySet();
    for (Map.Entry<String, Pod> entry : entries) {
        String podId = entry.getKey();
        Pod pod = entry.getValue();
        serviceProxy.entityChanged(podId, pod);
    }
    System.out.println("Service now initialised as: " + service);
}

From source file:com.google.idea.blaze.base.model.SyncState.java

SyncState(ImmutableMap<Class, Serializable> syncStateMap) {
    ImmutableMap.Builder<String, Serializable> extraProjectSyncStateMap = ImmutableMap.builder();
    for (Map.Entry<Class, Serializable> entry : syncStateMap.entrySet()) {
        extraProjectSyncStateMap.put(entry.getKey().getName(), entry.getValue());
    }//w  w  w  .j a va 2 s .  c  o  m
    this.syncStateMap = extraProjectSyncStateMap.build();
}

From source file:com.facebook.buck.shell.WorkerShellStep.java

@VisibleForTesting
String expandEnvironmentVariables(String string, ImmutableMap<String, String> variablesToExpand) {
    for (Map.Entry<String, String> variable : variablesToExpand.entrySet()) {
        string = string.replace("$" + variable.getKey(), variable.getValue())
                .replace("${" + variable.getKey() + "}", variable.getValue());
    }/*from w  ww .ja va 2 s .com*/
    return string;
}

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

@Override
public void putAll(Map<? extends K, ? extends V> m) {
    while (true) {
        ImmutableMap<K, V> original = m_map.get();
        Builder<K, V> builder = new Builder<K, V>();
        for (Map.Entry<K, V> entry : original.entrySet()) {
            if (!m.containsKey(entry.getKey())) {
                builder.put(entry);//from  ww  w . ja va 2s .c om
            }
        }
        builder.putAll(m);
        ImmutableMap<K, V> copy = builder.build();
        if (m_map.compareAndSet(original, copy)) {
            return;
        }
    }
}

From source file:org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase.java

private void addMatchedQueries(HitContext hitContext, ImmutableMap<String, Filter> namedFiltersAndQueries,
        List<String> matchedQueries) {
    for (Map.Entry<String, Filter> entry : namedFiltersAndQueries.entrySet()) {
        String name = entry.getKey();
        Filter filter = entry.getValue();
        try {//from  w ww  .ja v a 2  s  .  c om
            DocIdSet docIdSet = filter.getDocIdSet(hitContext.readerContext(), null); // null is fine, since we filter by hitContext.docId()
            if (!DocIdSets.isEmpty(docIdSet)) {
                Bits bits = docIdSet.bits();
                if (bits != null) {
                    if (bits.get(hitContext.docId())) {
                        matchedQueries.add(name);
                    }
                } else {
                    DocIdSetIterator iterator = docIdSet.iterator();
                    if (iterator != null) {
                        if (iterator.advance(hitContext.docId()) == hitContext.docId()) {
                            matchedQueries.add(name);
                        }
                    }
                }
            }
        } catch (IOException e) {
            // ignore
        } finally {
            SearchContext.current().clearReleasables(Lifetime.COLLECTION);
        }
    }
}

From source file:com.googlecode.jmxtrans.connections.JMXConnectionParams.java

/**
 * Convert values in a map to ensure all arrays are transformed to lists.
 *
 * This is an ugly workaround for https://github.com/jmxtrans/jmxtrans/issues/190. We need to ensure that
 * environments containing arrays of same values are treated as equals for the purpose of hashCode() and equals().
 */// ww  w  .  j  av a 2  s . c om
private ImmutableMap<String, ?> convertArraysToLists(ImmutableMap<String, ?> map) {
    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
        if (entry.getValue().getClass().isArray()) {
            builder.put(entry.getKey(), asList(entry.getValue()));
        } else {
            builder.put(entry.getKey(), entry.getValue());
        }
    }
    return builder.build();
}

From source file:com.spectralogic.ds3client.helpers.strategy.transferstrategy.PutJobTransferMethod.java

private void addMetadata(final BulkObject blob, final PutObjectRequest putObjectRequest) {
    if (metadataAccess != null) {
        final Map<String, String> metadata = metadataAccess.getMetadataValue(blob.getName());
        if (!Guard.isMapNullOrEmpty(metadata)) {
            final ImmutableMap<String, String> immutableMetadata = ImmutableMap.copyOf(metadata);
            for (final Map.Entry<String, String> value : immutableMetadata.entrySet()) {
                putObjectRequest.withMetaData(value.getKey(), value.getValue());
            }//from  w w  w .j  a v a2s.  c o  m
        }
    }
}