Skip to content

Add LookUpCache.contents(BiConsumer<K,V>) #4114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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