List of usage examples for com.google.common.collect Maps immutableEntry
@GwtCompatible(serializable = true) public static <K, V> Entry<K, V> immutableEntry(@Nullable K key, @Nullable V value)
From source file:com.uber.tchannel.tracing.PrefixedHeadersCarrier.java
@Override public Iterator<Map.Entry<String, String>> iterator() { final Iterator<Map.Entry<String, String>> iterator = headers.entrySet().iterator(); return new AbstractIterator<Map.Entry<String, String>>() { @Override/* w w w. j a v a2s . c o m*/ protected Map.Entry<String, String> computeNext() { while (iterator.hasNext()) { Map.Entry<String, String> entry = iterator.next(); if (entry.getKey().startsWith(prefix)) { return Maps.immutableEntry(decoder.apply(entry.getKey()), entry.getValue()); } } return this.endOfData(); } }; }
From source file:org.onosproject.store.primitives.impl.TranscodingAsyncConsistentTreeMap.java
@Override public CompletableFuture<Map.Entry<String, Versioned<V1>>> ceilingEntry(String key) { return backingMap.ceilingEntry(key).thenApply( entry -> Maps.immutableEntry(entry.getKey(), versionedValueTransform.apply(entry.getValue()))); }
From source file:org.hashtrees.store.SimpleMemStore.java
public Iterator<Map.Entry<byte[], byte[]>> iterator() { return Iterators.transform(kvMap.entrySet().iterator(), new Function<Map.Entry<ByteBuffer, ByteBuffer>, Map.Entry<byte[], byte[]>>() { @Override/*from w w w . j ava 2 s. co m*/ public Entry<byte[], byte[]> apply(final Entry<ByteBuffer, ByteBuffer> input) { return Maps.immutableEntry(input.getKey().array(), input.getValue().array()); }; }); }
From source file:ec.tss.tsproviders.sdmx.engine.GuessingCompactFactory.java
private static ImmutableList<Map.Entry<String, String>> getKey(Node seriesNode) { return asStream(seriesNode.getAttributes()).filter(o -> !TIME_FORMAT_ATTRIBUTE.equals(o.getNodeName())) .map(o -> Maps.immutableEntry(o.getNodeName(), o.getNodeValue())).collect(toImmutableList()); }
From source file:org.jooby.internal.elasticsearch.EmbeddedHttpRequest.java
@Override public Iterable<Entry<String, String>> headers() { ImmutableList.Builder<Entry<String, String>> headers = ImmutableList.builder(); req.headers().forEach((k, v) -> headers.add(Maps.immutableEntry(k, v.value()))); return headers.build(); }
From source file:io.atomix.core.map.impl.TranscodingAsyncDistributedMap.java
public TranscodingAsyncDistributedMap(AsyncDistributedMap<K2, V2> backingMap, Function<K1, K2> keyEncoder, Function<K2, K1> keyDecoder, Function<V1, V2> valueEncoder, Function<V2, V1> valueDecoder) { super(backingMap); this.backingMap = backingMap; this.keyEncoder = k -> k == null ? null : keyEncoder.apply(k); this.keyDecoder = k -> k == null ? null : keyDecoder.apply(k); this.valueEncoder = v -> v == null ? null : valueEncoder.apply(v); this.valueDecoder = v -> v == null ? null : valueDecoder.apply(v); this.entryDecoder = e -> e == null ? null : Maps.immutableEntry(keyDecoder.apply(e.getKey()), valueDecoder.apply(e.getValue())); this.entryEncoder = e -> e == null ? null : Maps.immutableEntry(keyEncoder.apply(e.getKey()), valueEncoder.apply(e.getValue())); }
From source file:com.kolich.curacao.mappers.request.types.body.EncodedRequestBodyMapper.java
private static final Map.Entry<String, String> getNextNameValuePair(final StringBuffer buffer, final Cursor cursor) { boolean terminated = false; int pos = cursor.getPosition(), indexFrom = cursor.getPosition(), indexTo = cursor.getUpperBound(); // Find name/*from w w w . j a va 2s. c o m*/ String name = null; while (pos < indexTo) { final char ch = buffer.charAt(pos); if (ch == KEY_VALUE_EQUALS) { break; } if (ch == DELIMITER) { terminated = true; break; } pos++; } if (pos == indexTo) { terminated = true; name = buffer.substring(indexFrom, indexTo).trim(); } else { name = buffer.substring(indexFrom, pos).trim(); pos++; } if (terminated) { cursor.updatePosition(pos); return Maps.immutableEntry(name, null); } // Find value String value = null; int i1 = pos; boolean quoted = false, escaped = false; while (pos < indexTo) { char ch = buffer.charAt(pos); if (ch == VALUE_DOUBLE_QUOTE && !escaped) { quoted = !quoted; } if (!quoted && !escaped && ch == DELIMITER) { terminated = true; break; } if (escaped) { escaped = false; } else { escaped = quoted && ch == '\\'; } pos++; } int i2 = pos; // Trim leading white space while (i1 < i2 && (Whitespace.isWhitespace(buffer.charAt(i1)))) { i1++; } // Trim trailing white space while ((i2 > i1) && (Whitespace.isWhitespace(buffer.charAt(i2 - 1)))) { i2--; } // Strip away quotes if necessary if (((i2 - i1) >= 2) && (buffer.charAt(i1) == '"') && (buffer.charAt(i2 - 1) == '"')) { i1++; i2--; } value = buffer.substring(i1, i2); if (terminated) { pos++; } cursor.updatePosition(pos); return Maps.immutableEntry(name, value); }
From source file:com.facebook.presto.sql.planner.plan.Assignments.java
public Assignments rewrite(Function<Expression, Expression> rewrite) { return assignments.entrySet().stream() .map(entry -> Maps.immutableEntry(entry.getKey(), rewrite.apply(entry.getValue()))) .collect(toAssignments());/*from www . ja va 2 s. c o m*/ }
From source file:de.cosmocode.collections.event.EventMap.java
@Override public V put(K key, V value) { final boolean contained = containsKey(key); final V removed = super.put(key, value); // was the key present before? if (contained) { listener.removed(Maps.immutableEntry(key, removed)); }/*w w w .jav a 2 s. c o m*/ // does the new value differ from the old one? if (removed != value) { listener.added(Maps.immutableEntry(key, value)); } return removed; }
From source file:ninja.leaping.permissionsex.backend.AbstractDataStore.java
@Override public final ImmutableSubjectData getData(String type, String identifier, Caching<ImmutableSubjectData> listener) { Objects.requireNonNull(type, "type"); Objects.requireNonNull(identifier, "identifier"); try {// w ww .j a v a 2s . co m ImmutableSubjectData ret = getDataInternal(type, identifier); if (listener != null) { listeners.addListener(Maps.immutableEntry(type, identifier), listener); } return ret; } catch (PermissionsLoadingException e) { throw new RuntimeException(e); } }