Skip to content

Commit

Permalink
Add LookUpCache.contents() (#4114)
Browse files Browse the repository at this point in the history
  • Loading branch information
JooHyukKim authored Sep 12, 2023
1 parent 3e4ab84 commit 52330fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ public V putIfAbsent(K key, V value) {
@Override
public int size() { return _map.size(); }

/*
/**********************************************************************
/* Extended API (2.14)
/**********************************************************************
*/

@Override
public void contents(BiConsumer<K,V> consumer) {
for (Map.Entry<K,V> entry : _map.entrySet()) {
consumer.accept(entry.getKey(), entry.getValue());
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/fasterxml/jackson/databind/util/LookupCache.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.fasterxml.jackson.databind.util;

import java.util.function.BiConsumer;

/**
* An interface describing the required API for the Jackson-databind Type cache.
*<p>
Expand All @@ -11,6 +13,20 @@
*/
public interface LookupCache<K,V>
{
/**
* Method to apply operation on cache contents without exposing them.
*<p>
* Default implementation throws {@link UnsupportedOperationException}.
* Implementations are required to override this method.
*
* @since 2.16
* @throws UnsupportedOperationException if implementation does not override this method.
* @param consumer Operation to apply on cache contents.
*/
default void contents(BiConsumer<K,V> consumer) {
throw new UnsupportedOperationException();
}

/**
* Method needed for creating clones but without contents.
*<p>
Expand Down

0 comments on commit 52330fa

Please sign in to comment.