This implementation of getAllPresent lacks any insight into the internal cache data structure, and is thus forced to return the query keys instead of the cached keys. This is only possible with an unsafe cast which requires keys to actually be of type K. {@inheritDoc} @sinc
(Iterable<?> keys)
| 65 | */ |
| 66 | |
| 67 | @Override |
| 68 | public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) { |
| 69 | Map<K, V> result = Maps.newLinkedHashMap(); |
| 70 | for (Object key : keys) { |
| 71 | if (!result.containsKey(key)) { |
| 72 | @SuppressWarnings("unchecked") |
| 73 | K castKey = (K) key; |
| 74 | V value = getIfPresent(key); |
| 75 | if (value != null) { |
| 76 | result.put(castKey, value); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | return ImmutableMap.copyOf(result); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @since 11.0 |
nothing calls this directly
no test coverage detected