Skip to content

Commit 52330fa

Browse files
authored
Add LookUpCache.contents() (#4114)
1 parent 3e4ab84 commit 52330fa

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/main/java/com/fasterxml/jackson/databind/util/LRUMap.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ public V putIfAbsent(K key, V value) {
7474
@Override
7575
public int size() { return _map.size(); }
7676

77-
/*
78-
/**********************************************************************
79-
/* Extended API (2.14)
80-
/**********************************************************************
81-
*/
82-
77+
@Override
8378
public void contents(BiConsumer<K,V> consumer) {
8479
for (Map.Entry<K,V> entry : _map.entrySet()) {
8580
consumer.accept(entry.getKey(), entry.getValue());

src/main/java/com/fasterxml/jackson/databind/util/LookupCache.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.fasterxml.jackson.databind.util;
22

3+
import java.util.function.BiConsumer;
4+
35
/**
46
* An interface describing the required API for the Jackson-databind Type cache.
57
*<p>
@@ -11,6 +13,20 @@
1113
*/
1214
public interface LookupCache<K,V>
1315
{
16+
/**
17+
* Method to apply operation on cache contents without exposing them.
18+
*<p>
19+
* Default implementation throws {@link UnsupportedOperationException}.
20+
* Implementations are required to override this method.
21+
*
22+
* @since 2.16
23+
* @throws UnsupportedOperationException if implementation does not override this method.
24+
* @param consumer Operation to apply on cache contents.
25+
*/
26+
default void contents(BiConsumer<K,V> consumer) {
27+
throw new UnsupportedOperationException();
28+
}
29+
1430
/**
1531
* Method needed for creating clones but without contents.
1632
*<p>

0 commit comments

Comments
 (0)