package aiyh.utils.mapUtil; import java.util.HashMap; import java.util.Map; /** * @author EBU7-dev1-ayh * @date 2021/8/19 0019 19:45 * utilMap */ public class UtilHashMap extends HashMap implements Map { public UtilHashMap(){ super(); } public UtilHashMap uPut(K key, V value) { this.put(key,value); return this; } public UtilHashMap uPutAll(Map m) { super.putAll(m); return this; } public UtilHashMap uReplace(K key, V value) { super.replace(key, value); return this; } public UtilHashMap filter(UtilMapFilter predicate){ UtilHashMap newMap = new UtilHashMap<>(); for (Entry entry : this.entrySet()){ if(predicate.test(entry.getKey(), entry.getValue())){ newMap.put(entry.getKey(),entry.getValue()); } } return newMap; } }