001package com.identityworksllc.iiq.common; 002 003import java.util.Collection; 004import java.util.Map; 005import java.util.Set; 006 007/** 008 * A Map interface that delegates all calls by default to the contained Map. This 009 * is useful for situations where the implementation of the Map is the new behavior, 010 * not the implementation of the individual methods. 011 * 012 * The delegate Map is whatever is returned from {@link #getDelegate()}. 013 * 014 * @param <K> The key type 015 * @param <V> The value type 016 */ 017public interface DelegatedMap<K, V> extends Map<K, V> { 018 default void clear() { 019 getDelegate().clear(); 020 } 021 022 default boolean containsKey(Object key) { 023 return getDelegate().containsKey(key); 024 } 025 026 default boolean containsValue(Object value) { 027 return getDelegate().containsValue(value); 028 } 029 030 default Set<Entry<K, V>> entrySet() { 031 return getDelegate().entrySet(); 032 } 033 034 default V get(Object key) { 035 return getDelegate().get(key); 036 } 037 038 /** 039 * Gets the map to which all other {@link Map} calls are delegated 040 * @return The Map to which all calls are delegated 041 */ 042 Map<K, V> getDelegate(); 043 044 default boolean isEmpty() { 045 return getDelegate().isEmpty(); 046 } 047 048 default Set<K> keySet() { 049 return getDelegate().keySet(); 050 } 051 052 default V put(K key, V value) { 053 return getDelegate().put(key, value); 054 } 055 056 default void putAll(Map<? extends K, ? extends V> m) { 057 getDelegate().putAll(m); 058 } 059 060 default V remove(Object key) { 061 return getDelegate().remove(key); 062 } 063 064 default int size() { 065 return getDelegate().size(); 066 } 067 068 default Collection<V> values() { 069 return getDelegate().values(); 070 } 071 072}