Example usage for com.google.common.collect Maps immutableEntry

List of usage examples for com.google.common.collect Maps immutableEntry

Introduction

In this page you can find the example usage for com.google.common.collect Maps immutableEntry.

Prototype

@GwtCompatible(serializable = true)
public static <K, V> Entry<K, V> immutableEntry(@Nullable K key, @Nullable V value) 

Source Link

Document

Returns an immutable map entry with the specified key and value.

Usage

From source file:com.cloudera.director.aws.ec2.EC2Provider.java

/**
 * <p>Zip two collections as a lazy iterable of pairs.</p>
 * <p><em>Note:</em> the returned iterable is not suitable for repeated use, since it
 * exhausts the iterator over the first collection.</p>
 *
 * @throws IllegalArgumentException if input collections don't have the same size
 *///from  w ww .jav a2  s  . c  om
private <K, V> Iterable<Map.Entry<K, V>> zipWith(Collection<K> a, Collection<V> b) {
    checkArgument(a.size() == b.size(), "collections don't have the same size");

    final Iterator<K> iterator = a.iterator();
    return Iterables.transform(b, new Function<V, Map.Entry<K, V>>() {
        @Override
        public Map.Entry<K, V> apply(V input) {
            return Maps.immutableEntry(iterator.next(), input);
        }
    });
}

From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService.java

@Override
public void addGarbageCollectionSentinelValues(String tableName, Set<Cell> cells) {
    try {// ww  w .  j a  v a2s.  co  m
        final Value value = Value.create(PtBytes.EMPTY_BYTE_ARRAY, Value.INVALID_VALUE_TIMESTAMP);
        putInternal(tableName, Iterables.transform(cells, new Function<Cell, Map.Entry<Cell, Value>>() {
            @Override
            public Entry<Cell, Value> apply(Cell cell) {
                return Maps.immutableEntry(cell, value);
            }
        }));
    } catch (Exception e) {
        throw Throwables.throwUncheckedException(e);
    }
}