Преглед на файлове

resolve #73
rename everything inside MapUtils & IntMapUtils
new: IntSetUtils

Mariusz Czarnowski преди 3 години
родител
ревизия
b8329171c3

+ 218 - 91
assira.commons/src/main/java/net/ranides/assira/collection/maps/IntMapUtils.java

@@ -6,18 +6,24 @@
  */
 package net.ranides.assira.collection.maps;
 
+import java.util.function.IntUnaryOperator;
 import lombok.experimental.UtilityClass;
+import net.ranides.assira.collection.ACollection;
 import net.ranides.assira.collection.CollectionUtils;
 import net.ranides.assira.collection.sets.IntSet;
+import net.ranides.assira.collection.sets.IntSetUtils;
 import net.ranides.assira.collection.sets.SetUtils;
 import net.ranides.assira.functional.covariant.ProjectionFunction;
 import net.ranides.assira.generic.CompareUtils;
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 import java.util.function.BiFunction;
 import java.util.function.Function;
+import java.util.function.IntPredicate;
 
 /**
  * Utility methods for IntMap, especially virtual transformations.
@@ -27,8 +33,6 @@ import java.util.function.Function;
 @UtilityClass
 public final class IntMapUtils {
 
-    // @todo #73 Review IntMapUtils adapter, projection, wrapper classes
-
     /**
      * Creates view which transforms values stored inside source map.
      * Returned view does not support modifications.
@@ -39,8 +43,8 @@ public final class IntMapUtils {
      * @param <RV> target type
      * @return read-only view
      */
-    public static <TV, RV> IntMap<RV> map(IntMap<TV> map, Function<? super TV, ? extends RV> function) {
-        return new MapAdapterKV<>(map, function, null);
+    public static <TV, RV> IntMap<RV> valueAdapter(IntMap<TV> map, Function<? super TV, ? extends RV> function) {
+        return new MapAdapter<>(map, function, null);
     }
 
     /**
@@ -48,13 +52,14 @@ public final class IntMapUtils {
      * Returned view supports modifications: it uses passed projection for conversion in both directions.
      *
      * @param map source map
-     * @param function mapping projection
+     * @param projection mapping projection
      * @param <TV> source type
      * @param <RV> target type
      * @return mutable view
      */
-    public static <TV, RV> IntMap<RV> map(IntMap<TV> map, ProjectionFunction<TV, RV> function) {
-        return new MapProjection<>(map, function);
+    public static <TV, RV> IntMap<RV> valueProjection(IntMap<TV> map, ProjectionFunction<TV, RV> projection) {
+        return new MapAdapter<>(map, projection, (Serializable & BiFunction<Integer,RV,RV>)(k,v) -> projection.apply(map.put(k, projection.invert(v))));
+
     }
 
     /**
@@ -69,8 +74,8 @@ public final class IntMapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <TV, RV> IntMap<RV> mapKV(IntMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> inserter) {
-        return new MapAdapterKV<>(map, function, inserter);
+    public static <TV, RV> IntMap<RV> valueProjection(IntMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> inserter) {
+        return new MapAdapter<>(map, function, inserter);
     }
 
     /**
@@ -85,8 +90,8 @@ public final class IntMapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <TV, RV> IntMap<RV> mapVV(IntMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
-        return new MapAdapterVV<>(map, function, replacer);
+    public static <TV, RV> IntMap<RV> valueDelegate(IntMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
+        return new MapDelegate<>(map, function, replacer);
     }
 
     /**
@@ -102,8 +107,8 @@ public final class IntMapUtils {
      * @param <RV> target type
      * @return read-only view
      */
-    public static <TV, RV> IntMultiMap<RV> map(IntMultiMap<TV> map, Function<? super TV, ? extends RV> function) {
-        return new MultiMapAdapterKV<>(map, function, null);
+    public static <TV, RV> IntMultiMap<RV> valueAdapter(IntMultiMap<TV> map, Function<? super TV, ? extends RV> function) {
+        return new MultiMapAdapter<>(map, function, null);
     }
 
     /**
@@ -114,13 +119,13 @@ public final class IntMapUtils {
      * contains more than one pair of (k,v) where BOTH k and v are equal.
      *
      * @param map source map
-     * @param function mapping projection
+     * @param projection mapping projection
      * @param <TV> source type
      * @param <RV> target type
      * @return mutable view
      */
-    public static <TV, RV> IntMultiMap<RV> map(IntMultiMap<TV> map, ProjectionFunction<TV, RV> function) {
-        return new MultiMapProjection<>(map, function);
+    public static <TV, RV> IntMultiMap<RV> valueProjection(IntMultiMap<TV> map, ProjectionFunction<TV, RV> projection) {
+        return new MultiMapAdapter<>(map, projection, (k,v) -> projection.apply(map.put(k, projection.invert(v))));
     }
 
     /**
@@ -137,8 +142,8 @@ public final class IntMapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <TV, RV> IntMultiMap<RV> mapKV(IntMultiMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> inserter) {
-        return new MultiMapAdapterKV<>(map, function, inserter);
+    public static <TV, RV> IntMultiMap<RV> valueProjection(IntMultiMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> inserter) {
+        return new MultiMapAdapter<>(map, function, inserter);
     }
 
     /**
@@ -156,17 +161,59 @@ public final class IntMapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <TV, RV> IntMultiMap<RV> mapVV(IntMultiMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
-        return new MultiMapAdapterVV<>(map, function, replacer);
+    public static <TV, RV> IntMultiMap<RV> valueDelegate(IntMultiMap<TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
+        return new MultiMapDelegate<>(map, function, replacer);
+    }
+
+    /**
+     * Returns read-only view which filters keys and maps them by provided function
+     *
+     * At access time it checks if provided key is accepted by "acceptor"
+     * At access time it maps accepted key by "function" and returns value from source map.
+     *
+     * @param content content
+     * @param acceptor acceptor
+     * @param <V> V
+     * @return view
+     */
+    public static <V> IntMap<V> keyFilter(IntMap<V> content, IntPredicate acceptor) {
+        return new KeyFilter<>(content, acceptor);
+    }
+
+    /**
+     * It cretes read-only view of map which keys are created by provided functions.
+     * Maps keys at access time, before lookup.
+     *
+     * @param map map
+     * @param keyMapper keyMapper
+     * @param <V> V
+     * @return view
+     */
+    public static <V> IntMap<V> keyMap(IntMap<? extends V> map, IntUnaryOperator keyMapper) {
+        return new KeyAdapter<>(map, keyMapper, Function.identity());
+    }
+
+    /**
+     * It cretes read-only view of map which keys are created by provided functions.
+     * Maps keys at access time, before lookup.
+     *
+     * @param map map
+     * @param keyMapper keyMapper
+     * @param <TV> TV
+     * @param <RV> RV
+     * @return view
+     */
+    public static <TV, RV> IntMap<RV> keyMap(IntMap<? extends TV> map, IntUnaryOperator keyMapper, Function<TV, RV> valueMapper) {
+        return new KeyAdapter<>(map, keyMapper, valueMapper);
     }
 
-    private static class MultiMapAdapterKV<TV, RV> extends MapAdapterKV<TV, RV> implements IntMultiMap<RV> {
+    private static class MultiMapAdapter<TV, RV> extends MapAdapter<TV, RV> implements IntMultiMap<RV> {
 
         private static final long serialVersionUID = 1L;
 
         private final IntMultiMap<TV> mcontent;
 
-        public MultiMapAdapterKV(IntMultiMap<TV> mcontent, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> setter) {
+        public MultiMapAdapter(IntMultiMap<TV> mcontent, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> setter) {
             super(mcontent, function, setter);
             this.mcontent = mcontent;
         }
@@ -178,13 +225,13 @@ public final class IntMapUtils {
 
     }
 
-    private static class MultiMapAdapterVV<TV, RV> extends MapAdapterVV<TV,RV> implements IntMultiMap<RV> {
+    private static class MultiMapDelegate<TV, RV> extends MapDelegate<TV,RV> implements IntMultiMap<RV> {
 
         private static final long serialVersionUID = 1L;
 
         private final IntMultiMap<TV> mcontent;
 
-        public MultiMapAdapterVV(IntMultiMap<TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
+        public MultiMapDelegate(IntMultiMap<TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
             super(content, getter, setter);
             this.mcontent = content;
         }
@@ -196,25 +243,7 @@ public final class IntMapUtils {
 
     }
 
-    private static class MultiMapProjection<TV, RV> extends MapProjection<TV,RV> implements IntMultiMap<RV> {
-
-        private static final long serialVersionUID = 1L;
-
-        private final IntMultiMap<TV> mcontent;
-
-        public MultiMapProjection(IntMultiMap<TV> content, ProjectionFunction<TV, RV> function) {
-            super(content, function);
-            this.mcontent = content;
-        }
-
-        @Override
-        public Collection<RV> getAll(int key) {
-            return CollectionUtils.map(mcontent.getAll(key), function);
-        }
-
-    }
-
-    private static class MapAdapterKV<TV, RV> extends AIntMap<RV> {
+    private static class MapAdapter<TV, RV> extends AIntMap<RV> {
         
         private static final long serialVersionUID = 1L;
         
@@ -228,7 +257,7 @@ public final class IntMapUtils {
         protected final BiFunction<Integer, ? super RV, ? extends RV> inserter;
 
         @SuppressWarnings("unchecked")
-        public MapAdapterKV(IntMap<TV> content, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> inserter) {
+        public MapAdapter(IntMap<TV> content, Function<? super TV, ? extends RV> function, BiFunction<Integer, ? super RV, ? extends RV> inserter) {
             this.content = content;
             this.function = function;
             this.inserter = null != inserter ? inserter : NSE;
@@ -313,7 +342,7 @@ public final class IntMapUtils {
 
     }
 
-    private static class MapAdapterVV<TV, RV> extends AIntMap<RV> implements IntMap<RV> {
+    private static class MapDelegate<TV, RV> extends AIntMap<RV> implements IntMap<RV> {
 
         private static final long serialVersionUID = 1L;
 
@@ -321,7 +350,7 @@ public final class IntMapUtils {
         protected final Function<? super TV, ? extends RV> getter;
         protected final BiFunction<? super TV, ? super RV, ? extends RV> setter;
 
-        public MapAdapterVV(IntMap<TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
+        public MapDelegate(IntMap<TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
             this.content = content;
             this.getter = getter;
             this.setter = setter;
@@ -396,16 +425,18 @@ public final class IntMapUtils {
         
     }
 
-    private static class MapProjection<TV, RV> extends AIntMap<RV> {
+    private static class KeyAdapter<TV, RV> extends AIntMap<RV> {
 
-        private static final long serialVersionUID = 1L;
+        private final IntMap<? extends TV> content;
 
-        protected final IntMap<TV> content;
-        protected final ProjectionFunction<TV, RV> function;
+        private final IntUnaryOperator kmap;
+
+        private final Function<TV, RV> vmap;
 
-        public MapProjection(IntMap<TV> content, ProjectionFunction<TV, RV> function) {
+        public KeyAdapter(IntMap<? extends TV> content, IntUnaryOperator kmap, Function<TV, RV> vmap) {
             this.content = content;
-            this.function = function;
+            this.kmap = kmap;
+            this.vmap = vmap;
         }
 
         @Override
@@ -415,94 +446,190 @@ public final class IntMapUtils {
 
         @Override
         public boolean containsKey(int key) {
-            return content.containsKey(key);
+            return content.containsKey(kmap.applyAsInt(key));
         }
 
         @Override
+        public RV get(int key) {
+            return vmap.apply(content.get(kmap.applyAsInt(key)));
+        }
+
         @SuppressWarnings("unchecked")
+        @Override
         public boolean containsValue(Object value) {
-            Object v;
             try {
-                v = function.invert((RV)value);
-            } catch(ClassCastException _ex) {
+                return content.containsValue(vmap.apply((TV) value));
+            } catch (ClassCastException e) {
                 return false;
             }
-            return content.containsValue(v);
+        }
+
+        @Override public IntSet keySet() {
+            return IntSetUtils.map(content.keySet(), kmap);
+        }
+
+        @Override public Collection<RV> values() {
+            return CollectionUtils.map(content.values(), vmap);
+        }
+
+        @Override public void putAll(Map<? extends Integer, ? extends RV> values) {
+            super.putAll(values);
+        }
+
+        @Override public Set<IntEntry<RV>> fastEntrySet() {
+            return SetUtils.map(content.entrySet(), e -> new BasicEntry<>(kmap.applyAsInt(e.getKey()), vmap.apply(e.getValue())));
+        }
+
+    }
+
+    private static class KeyFilter<V> extends AIntMap<V> {
+
+        protected final IntMap<V> content;
+        protected final IntPredicate filter;
+
+        KeyFilter(IntMap<V> content, IntPredicate acceptor) {
+            this.content = content;
+            this.filter = acceptor;
+        }
+
+        @Override public Set<IntEntry<V>> fastEntrySet() {
+            return new KeyMapEntrySet();
         }
 
         @Override
-        public void clear() {
-            content.clear();
+        public int size() {
+            return content.size();
         }
 
         @Override
-        public RV remove(int key) {
-            TV prev = content.remove(key);
-            return prev==null ? null : function.apply(prev);
+        public boolean containsValue(Object value) {
+            return content.containsValue(value);
         }
 
         @Override
-        public IntSet keySet() {
-            return content.keySet();
+        public V get(int key) {
+            return filter.test(key) ? content.get(key) : null;
         }
 
         @Override
-        public Collection<RV> values() {
-            return CollectionUtils.map(content.values(), function);
+        public V getOrDefault(Object key, V defaultValue) {
+            return (key instanceof Integer) && filter.test((int)key) ? content.getOrDefault(key, defaultValue) : defaultValue;
         }
 
         @Override
-        public Set<IntEntry<RV>> fastEntrySet() {
-            return SetUtils.map(content.fastEntrySet(), e -> new EntryProjection(e));
+        public boolean containsKey(int key) {
+            return filter.test(key) && content.containsKey(key);
         }
 
         @Override
-        public RV get(int key) {
-            return function.apply(content.get(key));
+        public V put(int key, V value) {
+            return content.put(key, value);
         }
 
         @Override
-        public RV put(int key, RV value) {
-            return function.apply(content.put(key, function.invert(value)));
+        public void putAll(Map<? extends Integer, ? extends V> m) {
+            for (Map.Entry<? extends Integer, ? extends V> e : m.entrySet()) {
+                int key = e.getKey();
+                V value = e.getValue();
+                content.put(key, value);
+            }
+        }
+
+        @Override
+        public V remove(int key) {
+            return filter.test(key) ? content.remove(key) : null;
+        }
+
+        @Override
+        public V putIfAbsent(Integer key, V value) {
+            return content.putIfAbsent(key, value);
         }
 
         @Override
-        @SuppressWarnings("unchecked")
         public boolean remove(int key, Object value) {
-            Object v;
-            try {
-                v = function.invert((RV)value);
-            } catch(ClassCastException _e) {
-                return false;
-            }
-            return content.remove(key, v);
+            return filter.test(key) && content.remove(key, value);
         }
 
-        private final class EntryProjection extends AIntEntry<RV> {
+        @Override
+        public boolean replace(Integer key, V oldValue, V newValue) {
+            return content.replace(key, oldValue, newValue);
+        }
 
-            private final IntEntry<TV> delegate;
+        @Override
+        public V replace(Integer key, V value) {
+            return content.replace(key, value);
+        }
 
-            public EntryProjection(IntEntry<TV> delegate) {
-                this.delegate = delegate;
+        @Override
+        public V computeIfAbsent(Integer key, Function<? super Integer, ? extends V> mappingFunction) {
+            return content.computeIfAbsent(key, mappingFunction);
+        }
+
+        @Override
+        public V computeIfPresent(Integer key, BiFunction<? super Integer, ? super V, ? extends V> remappingFunction) {
+            return content.computeIfPresent(key, remappingFunction);
+        }
+
+        @Override
+        public V compute(Integer key, BiFunction<? super Integer, ? super V, ? extends V> remappingFunction) {
+            return content.compute(key, remappingFunction);
+        }
+
+        @Override
+        public V merge(Integer key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
+            return content.merge(key, value, remappingFunction);
+        }
+
+        @SuppressWarnings("unchecked")
+        private IntEntry<V> $toSimpleEntry(IntEntry<?> entry) {
+            int k = entry.getIntKey();
+            V v = (V)entry.getValue();
+            return new BasicEntry<>(k, v);
+        }
+
+        private final class KeyMapEntrySet extends ACollection<IntEntry<V>> implements Set<IntEntry<V>>, Serializable {
+
+            private static final long serialVersionUID = 1L;
+
+            private final Set<IntEntry<V>> entries = content.fastEntrySet();
+
+            @Override
+            public boolean contains(Object o) {
+                return o instanceof Entry<?,?> && entries.contains($toSimpleEntry((IntEntry<?>)o));
             }
 
             @Override
-            public int getIntKey() {
-                return delegate.getIntKey();
+            public boolean add(IntEntry<V> kvEntry) {
+                return entries.add($toSimpleEntry(kvEntry));
             }
 
             @Override
-            public RV getValue() {
-                return function.apply(delegate.getValue());
+            public Iterator<IntEntry<V>> iterator() {
+                return entries.iterator();
             }
 
             @Override
-            public RV setValue(RV value) {
-                return function.apply(content.put(getIntKey(), function.invert(value)));
+            public int size() {
+                return entries.size();
+            }
+
+            @Override
+            public int hashCode() {
+                return entries.hashCode();
+            }
+
+            @Override
+            public boolean equals(Object obj) {
+                if(obj instanceof Set) {
+                    @SuppressWarnings("unchecked")
+                    Set<IntEntry<V>> that = (Set<IntEntry<V>>)obj;
+                    return this.size() == that.size() && this.containsAll(that);
+                }
+                return false;
             }
 
         }
 
     }
-    
+
 }

+ 2 - 2
assira.commons/src/test/java/net/ranides/assira/collection/maps/IntMapUtilsTest.java

@@ -28,7 +28,7 @@ public class IntMapUtilsTest {
         Function<int[], IntMap<String>> gf = (Function<int[], IntMap<String>> & Serializable)(int[] array) -> {
             IntMap<TWrapper<String>> mmap = new IntOpenMap<>();
             TWrapper.into(mmap, tmap.list(array));
-            return IntMapUtils.map(mmap, TWrapper.projection());
+            return IntMapUtils.valueProjection(mmap, TWrapper.projection());
         };
         
         ContractTesters.runner()
@@ -46,7 +46,7 @@ public class IntMapUtilsTest {
         Function<int[], IntMap<String>> gf = (Function<int[], IntMap<String>> & Serializable)(int[] array) -> {
             IntMap<TWrapper<String>> mmap = new IntOpenMap<>();
             TWrapper.into(mmap, tmap.list(array));
-            return IntMapUtils.map(mmap, TWrapper.unwrap());
+            return IntMapUtils.valueAdapter(mmap, TWrapper.unwrap());
         };
         
         ContractTesters.runner()

+ 137 - 255
assira.core/src/main/java/net/ranides/assira/collection/maps/MapUtils.java

@@ -38,13 +38,13 @@ public class MapUtils {
      * @param <RV> target type
      * @return read-only view
      */
-    public static <K, TV, RV> Map<K,RV> map(Map<K,TV> map, Function<? super TV, ? extends RV> function) {
-        return new MapAdapterKV<>(map, function, null);
+    public static <K, TV, RV> Map<K,RV> valueAdapter(Map<K,TV> map, Function<? super TV, ? extends RV> function) {
+        return new MapAdapter<>(map, function, null);
     }
 
     /**
      * Creates view which transforms values stored inside source map.
-     * Returned view supports modifications: it uses passed projection for conversion in both directions.
+     * Returned view supports insertions and replacements: it uses passed projection for conversion in both directions.
      *
      * @param map source map
      * @param projection projection
@@ -53,8 +53,8 @@ public class MapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <K, TV, RV> Map<K,RV> map(Map<K,TV> map, ProjectionFunction<TV, RV> projection) {
-        return new MapProjection<>(map, projection);
+    public static <K, TV, RV> Map<K,RV> valueProjection(Map<K,TV> map, ProjectionFunction<TV, RV> projection) {
+        return new MapAdapter<>(map, projection, (Serializable & BiFunction<K,RV,RV>)(k,v) -> projection.apply(map.put(k, projection.invert(v))));
     }
 
     /**
@@ -64,15 +64,15 @@ public class MapUtils {
      * It passes to inserter "key" and "new value".
      *
      * @param map source map
-     * @param function mapping function
+     * @param getter mapping function
      * @param inserter insertion function
      * @param <K> K
      * @param <TV> source type
      * @param <RV> target type
      * @return mutable view
      */
-    public static <K, TV, RV> Map<K,RV> mapKV(Map<K,TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> inserter) {
-        return new MapAdapterKV<>(map, function, inserter);
+    public static <K, TV, RV> Map<K,RV> valueProjection(Map<K,TV> map, Function<? super TV, ? extends RV> getter, BiFunction<? super K, ? super RV, ? extends RV> inserter) {
+        return new MapAdapter<>(map, getter, inserter);
     }
 
     /**
@@ -82,15 +82,15 @@ public class MapUtils {
      * It passes to replacer "previous value" and "new value".
      *
      * @param map source map
-     * @param function mapping function
-     * @param replacer insertion function
+     * @param getter mapping function
+     * @param setter insertion function
      * @param <K> K
      * @param <TV> source type
      * @param <RV> target type
      * @return mutable view
      */
-    public static <K, TV, RV> Map<K,RV> mapVV(Map<K,TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
-        return new MapAdapterVV<>(map, function, replacer);
+    public static <K, TV, RV> Map<K,RV> valueDelegate(Map<K,TV> map, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
+        return new MapDelegate<>(map, getter, setter);
     }
 
     /**
@@ -105,8 +105,8 @@ public class MapUtils {
      * @return read-only view
      */
     @SuppressWarnings("unchecked")
-    public static <K, TV, RV> MultiMap<K,RV> map(MultiMap<K,TV> map, Function<? super TV, ? extends RV> function) {
-        return new MultiMapAdapterKV<>(map, function, null);
+    public static <K, TV, RV> MultiMap<K,RV> valueAdapter(MultiMap<K,TV> map, Function<? super TV, ? extends RV> function) {
+        return new MultiMapAdapter<>(map, function, null);
     }
 
     /**
@@ -120,8 +120,8 @@ public class MapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <K, TV, RV> MultiMap<K,RV> map(MultiMap<K,TV> map, ProjectionFunction<TV, RV> projection) {
-        return new MultiMapProjection<>(map, projection);
+    public static <K, TV, RV> MultiMap<K,RV> valueProjection(MultiMap<K,TV> map, ProjectionFunction<TV, RV> projection) {
+        return new MultiMapAdapter<>(map, projection, (k,v) -> projection.apply(map.put(k, projection.invert(v))));
     }
 
     /**
@@ -137,8 +137,8 @@ public class MapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <K, TV, RV> MultiMap<K,RV> mapKV(MultiMap<K,TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> inserter) {
-        return new MultiMapAdapterKV<>(map, function, inserter);
+    public static <K, TV, RV> MultiMap<K,RV> valueProjection(MultiMap<K,TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> inserter) {
+        return new MultiMapAdapter<>(map, function, inserter);
     }
 
     /**
@@ -155,8 +155,8 @@ public class MapUtils {
      * @param <RV> target type
      * @return mutable view
      */
-    public static <K, TV, RV> MultiMap<K,RV> mapVV(MultiMap<K,TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
-        return new MultiMapAdapterVV<>(map, function, replacer);
+    public static <K, TV, RV> MultiMap<K,RV> valueDelegate(MultiMap<K,TV> map, Function<? super TV, ? extends RV> function, BiFunction<? super TV, ? super RV, ? extends RV> replacer) {
+        return new MultiMapDelegate<>(map, function, replacer);
     }
 
     /**
@@ -167,13 +167,12 @@ public class MapUtils {
      *
      * @param content content
      * @param acceptor acceptor
-     * @param function function
      * @param <K> K
      * @param <V> V
      * @return view
      */
-    public static <K,V> Map<K,V> keymap(Map<K, V> content, Predicate<Object> acceptor, Function<K, K> function) {
-        return new KeyMapFilter<>(content, acceptor, function);
+    public static <K,V> Map<K,V> keyFilter(Map<K, V> content, Predicate<Object> acceptor) {
+        return new KeyFilter<>(content, acceptor);
     }
 
     /**
@@ -184,11 +183,27 @@ public class MapUtils {
      * @param keyMapper keyMapper
      * @param <TK> TK
      * @param <RK> RK
-     * @param <V> V
+     * @param <V> TV
+     * @return view
+     */
+    public static <TK, RK, V> Map<RK, V> keyMap(Map<TK, ? extends V> map, Function<TK, RK> keyMapper) {
+        return new KeyAdapter<>(map, keyMapper, Function.identity());
+    }
+
+    /**
+     * It cretes read-only view of map which keys are created by provided functions.
+     * Maps keys at access time, before lookup.
+     *
+     * @param map map
+     * @param keyMapper keyMapper
+     * @param <TK> TK
+     * @param <RK> RK
+     * @param <TV> TV
+     * @param <RV> RV
      * @return view
      */
-    public static <TK, RK, V> Map<RK,V> keymap(Map<TK, ? extends V> map, Function<TK, RK> keyMapper) {
-        return new KeyMapAdapter<>(map, keyMapper, Function.identity());
+    public static <TK, RK, TV, RV> Map<RK,RV> keyMap(Map<TK, ? extends TV> map, Function<TK, RK> keyMapper, Function<TV, RV> valueMapper) {
+        return new KeyAdapter<>(map, keyMapper, valueMapper);
     }
 
     /**
@@ -272,126 +287,7 @@ public class MapUtils {
         return target;
     }
 
-    private static class KeyMapAdapter<TK, RK, TV, RV> extends AMap<RK, RV> {
-
-        private final Map<TK,? extends TV> content;
-
-        private final Function<TK, RK> kmap;
-
-        private final Function<TV, RV> vmap;
-
-        public KeyMapAdapter(Map<TK,? extends TV> content, Function<TK, RK> kmap, Function<TV, RV> vmap) {
-            this.content = content;
-            this.kmap = kmap;
-            this.vmap = vmap;
-        }
-
-        @Override
-        public int size() {
-            return content.size();
-        }
-
-        @SuppressWarnings("unchecked")
-        @Override
-        public boolean containsKey(Object key) {
-            try {
-                return content.containsKey(kmap.apply((TK) key));
-            } catch (ClassCastException e) {
-                return false;
-            }
-        }
-
-        @SuppressWarnings("unchecked")
-        @Override
-        public RV get(Object key) {
-            try {
-                return vmap.apply(content.get(kmap.apply((TK) key)));
-            } catch (ClassCastException e) {
-                return null;
-            }
-        }
-
-        @SuppressWarnings("unchecked")
-        @Override
-        public boolean containsValue(Object value) {
-            try {
-                return content.containsValue(vmap.apply((TV) value));
-            } catch (ClassCastException e) {
-                return false;
-            }
-        }
-
-        @Override
-        public Set<RK> keySet() {
-            return SetUtils.map(content.keySet(), kmap);
-        }
-
-        @Override
-        public Collection<RV> values() {
-            return CollectionUtils.map(content.values(), vmap);
-        }
-
-        @Override
-        public Set<Entry<RK, RV>> entrySet() {
-            return SetUtils.map(content.entrySet(), e -> new SimpleEntry<>(kmap.apply(e.getKey()), vmap.apply(e.getValue())));
-        }
-    }
-
-    private static class MultiMapAdapterKV<K, TV, RV> extends MapAdapterKV<K, TV, RV> implements MultiMap<K, RV> {
-        
-        private static final long serialVersionUID = 1L;
-        
-        private final MultiMap<K, TV> mcontent;
-
-        public MultiMapAdapterKV(MultiMap<K, TV> mcontent, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> setter) {
-            super(mcontent, function, setter);
-            this.mcontent = mcontent;
-        }
-        
-        @Override
-        public Collection<RV> getAll(Object key) {
-            return CollectionUtils.map(mcontent.getAll(key), function);
-        }
-        
-    }
-
-    private static class MultiMapAdapterVV<K, TV, RV> extends MapAdapterVV<K,TV,RV> implements MultiMap<K, RV> {
-
-        private static final long serialVersionUID = 1L;
-
-        private final MultiMap<K, TV> mcontent;
-
-        public MultiMapAdapterVV(MultiMap<K, TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
-            super(content, getter, setter);
-            this.mcontent = content;
-        }
-
-        @Override
-        public Collection<RV> getAll(Object key) {
-            return CollectionUtils.map(mcontent.getAll(key), getter);
-        }
-
-    }
-
-    private static class MultiMapProjection<K, TV, RV> extends MapProjection<K,TV,RV> implements MultiMap<K, RV> {
-        
-        private static final long serialVersionUID = 1L;
-        
-        private final MultiMap<K, TV> mcontent;
-        
-        public MultiMapProjection(MultiMap<K, TV> content, ProjectionFunction<TV, RV> function) {
-            super(content, function);
-            this.mcontent = content;
-        }
-        
-        @Override
-        public Collection<RV> getAll(Object key) {
-            return CollectionUtils.map(mcontent.getAll(key), function);
-        }
-
-    }
-
-    private static class MapAdapterKV<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
+    private static class MapAdapter<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
 
         private static final long serialVersionUID = 1L;
 
@@ -404,7 +300,7 @@ public class MapUtils {
         protected final BiFunction<? super K, ? super RV, ? extends RV> inserter;
 
         @SuppressWarnings("unchecked")
-        public MapAdapterKV(Map<K, TV> content, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> setter) {
+        public MapAdapter(Map<K, TV> content, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> setter) {
             this.content = content;
             this.function = function;
             this.inserter = null != setter ? setter : NSE;
@@ -488,7 +384,7 @@ public class MapUtils {
 
     }
 
-    private static class MapAdapterVV<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
+    private static class MapDelegate<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
 
         private static final long serialVersionUID = 1L;
 
@@ -496,7 +392,7 @@ public class MapUtils {
         protected final Function<? super TV, ? extends RV> getter;
         protected final BiFunction<? super TV, ? super RV, ? extends RV> setter;
 
-        public MapAdapterVV(Map<K,TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
+        public MapDelegate(Map<K,TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
             this.content = content;
             this.getter = getter;
             this.setter = setter;
@@ -525,8 +421,8 @@ public class MapUtils {
 
         @Override
         public RV put(K key, RV value) {
-            TV var = content.get(key);
-            return null!=var ? setter.apply(var, value) : null;
+            TV original = content.get(key);
+            return null!=original ? setter.apply(original, value) : null;
         }
 
         @Override
@@ -571,165 +467,151 @@ public class MapUtils {
 
     }
 
-    private static class MapProjection<K, TV, RV> extends AMap<K, RV> implements Map<K, RV> {
-        
-        private static final long serialVersionUID = 1L;
+    private static class MultiMapAdapter<K, TV, RV> extends MapAdapter<K, TV, RV> implements MultiMap<K, RV> {
 
-        protected final Map<K, TV> content;
+        private static final long serialVersionUID = 1L;
 
-        protected final ProjectionFunction<TV, RV> function;
+        private final MultiMap<K, TV> mcontent;
 
-        public MapProjection(Map<K, TV> content, ProjectionFunction<TV, RV> function) {
-            this.content = content;
-            this.function = function;
-        }
-        
-        public MapProjection(MultiMap<K, TV> content, ProjectionFunction<TV, RV> function) {
-            this.content = content;
-            this.function = function;
+        public MultiMapAdapter(MultiMap<K, TV> mcontent, Function<? super TV, ? extends RV> function, BiFunction<? super K, ? super RV, ? extends RV> setter) {
+            super(mcontent, function, setter);
+            this.mcontent = mcontent;
         }
 
         @Override
-        public int size() {
-            return content.size();
+        public Collection<RV> getAll(Object key) {
+            return CollectionUtils.map(mcontent.getAll(key), function);
         }
 
-        @Override
-        public boolean containsKey(Object key) {
-            return content.containsKey(key);
-        }
-        
-        @SuppressWarnings("unchecked")
-        @Override
-        public boolean containsValue(Object value) {
-            try {
-                return content.containsValue(function.invert((RV)value));
-            } catch(ClassCastException _ex) {
-                return false;
-            }
+    }
+
+    private static class MultiMapDelegate<K, TV, RV> extends MapDelegate<K,TV,RV> implements MultiMap<K, RV> {
+
+        private static final long serialVersionUID = 1L;
+
+        private final MultiMap<K, TV> mcontent;
+
+        public MultiMapDelegate(MultiMap<K, TV> content, Function<? super TV, ? extends RV> getter, BiFunction<? super TV, ? super RV, ? extends RV> setter) {
+            super(content, getter, setter);
+            this.mcontent = content;
         }
 
         @Override
-        public void clear() {
-            content.clear();
+        public Collection<RV> getAll(Object key) {
+            return CollectionUtils.map(mcontent.getAll(key), getter);
         }
 
+    }
+
+    static class EmptyMultiMap<K,V> extends AMap<K,V> implements MultiMap<K, V> {
+        
+        private static final long serialVersionUID = 1L;
+
         @Override
-        public RV remove(Object key) {
-            TV prev = content.remove(key);
-            return prev==null ? null : function.apply(prev);
+        public Set<Map.Entry<K, V>> entrySet() {
+            return Collections.emptySet();
         }
 
         @Override
-        public Set<K> keySet() {
-            return content.keySet();
+        public int size() {
+            return 0;
         }
 
         @Override
-        public Collection<RV> values() {
-            return CollectionUtils.map(content.values(), function);
+        public boolean containsKey(Object key) {
+            return false;
         }
-        
+
         @Override
-        public Set<Map.Entry<K, RV>> entrySet() {
-            return SetUtils.map(content.entrySet(), e -> new EntryProjection(e));
+        public boolean containsValue(Object value) {
+            return false;
         }
 
         @Override
-        public RV get(Object key) {
-            return function.apply(content.get(key));
+        public V get(Object key) {
+            return null;
         }
         
         @Override
-        public RV put(K key, RV value) {
-            return function.apply(content.put(key, function.invert(value)));
-        }
-
-        @Override
-        @SuppressWarnings("unchecked")
-        public boolean remove(Object key, Object value) {
-            Object v;
-            try {
-                v = function.invert((RV)value);
-            } catch(ClassCastException _e) {
-                return false;
-            }
-            return content.remove(key, v);
+        public Collection<V> getAll(Object key) {
+            return Collections.emptyList();
         }
 
-        private final class EntryProjection extends AEntry<K, RV> {
-            
-            private final Map.Entry<K,TV> delegate;
+    }
 
-            public EntryProjection(Map.Entry<K, TV> delegate) {
-                this.delegate = delegate;
-            }
+    private static class KeyAdapter<TK, RK, TV, RV> extends AMap<RK, RV> {
 
-            @Override
-            public K getKey() {
-                return delegate.getKey();
-            }
+        private final Map<TK,? extends TV> content;
 
-            @Override
-            public RV getValue() {
-                return function.apply(delegate.getValue());
-            }
+        private final Function<TK, RK> kmap;
 
-            @Override
-            public RV setValue(RV value) {
-                return function.apply(content.put(getKey(), function.invert(value)));
-            }
+        private final Function<TV, RV> vmap;
 
+        public KeyAdapter(Map<TK,? extends TV> content, Function<TK, RK> kmap, Function<TV, RV> vmap) {
+            this.content = content;
+            this.kmap = kmap;
+            this.vmap = vmap;
         }
 
-    }
-
-    static class EmptyMM<K,V> extends AMap<K,V> implements MultiMap<K, V> {
-        
-        private static final long serialVersionUID = 1L;
-
         @Override
-        public Set<Map.Entry<K, V>> entrySet() {
-            return Collections.emptySet();
+        public int size() {
+            return content.size();
         }
 
+        @SuppressWarnings("unchecked")
         @Override
-        public int size() {
-            return 0;
+        public boolean containsKey(Object key) {
+            try {
+                return content.containsKey(kmap.apply((TK) key));
+            } catch (ClassCastException e) {
+                return false;
+            }
         }
 
+        @SuppressWarnings("unchecked")
         @Override
-        public boolean containsKey(Object key) {
-            return false;
+        public RV get(Object key) {
+            try {
+                return vmap.apply(content.get(kmap.apply((TK) key)));
+            } catch (ClassCastException e) {
+                return null;
+            }
         }
 
+        @SuppressWarnings("unchecked")
         @Override
         public boolean containsValue(Object value) {
-            return false;
+            try {
+                return content.containsValue(vmap.apply((TV) value));
+            } catch (ClassCastException e) {
+                return false;
+            }
         }
 
         @Override
-        public V get(Object key) {
-            return null;
+        public Set<RK> keySet() {
+            return SetUtils.map(content.keySet(), kmap);
         }
-        
+
         @Override
-        public Collection<V> getAll(Object key) {
-            return Collections.emptyList();
+        public Collection<RV> values() {
+            return CollectionUtils.map(content.values(), vmap);
         }
 
+        @Override
+        public Set<Entry<RK, RV>> entrySet() {
+            return SetUtils.map(content.entrySet(), e -> new SimpleEntry<>(kmap.apply(e.getKey()), vmap.apply(e.getValue())));
+        }
     }
 
-    private static class KeyMapFilter<K, V> extends AMap<K, V> {
+    private static class KeyFilter<K, V> extends AMap<K, V> {
 
         protected final Map<K, V> content;
-        protected final Predicate<Object> acceptor;
-        protected final Function<K, K> function;
+        protected final Predicate<Object> filter;
 
-        KeyMapFilter(Map<K, V> content, Predicate<Object> acceptor, Function<K, K> function) {
+        KeyFilter(Map<K, V> content, Predicate<Object> acceptor) {
             this.content = content;
-            this.acceptor = acceptor;
-            this.function = function;
+            this.filter = acceptor;
         }
 
         @Override
@@ -749,17 +631,17 @@ public class MapUtils {
 
         @Override
         public V get(Object key) {
-            return acceptor.test(key) ? content.get($key(key)) : null;
+            return filter.test(key) ? content.get($key(key)) : null;
         }
 
         @Override
         public V getOrDefault(Object key, V defaultValue) {
-            return acceptor.test(key) ? content.getOrDefault($key(key), defaultValue) : defaultValue;
+            return filter.test(key) ? content.getOrDefault($key(key), defaultValue) : defaultValue;
         }
 
         @Override
         public boolean containsKey(Object key) {
-            return acceptor.test(key) && content.containsKey($key(key));
+            return filter.test(key) && content.containsKey($key(key));
         }
 
         @Override
@@ -778,7 +660,7 @@ public class MapUtils {
 
         @Override
         public V remove(Object key) {
-            return acceptor.test(key) ? content.remove($key(key)) : null;
+            return filter.test(key) ? content.remove($key(key)) : null;
         }
 
         @Override
@@ -788,7 +670,7 @@ public class MapUtils {
 
         @Override
         public boolean remove(Object key, Object value) {
-            return acceptor.test(key) && content.remove($key(key), value);
+            return filter.test(key) && content.remove($key(key), value);
         }
 
         @Override
@@ -823,7 +705,7 @@ public class MapUtils {
 
         @SuppressWarnings("unchecked")
         private K $key(Object key) {
-            return key!=null ? function.apply((K)key) : null;
+            return (K)key;
         }
 
         @SuppressWarnings("unchecked")

+ 2 - 1
assira.core/src/main/java/net/ranides/assira/collection/maps/MultiMap.java

@@ -15,6 +15,7 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.function.BinaryOperator;
 import java.util.function.Predicate;
+import net.ranides.assira.collection.maps.MapUtils.EmptyMultiMap;
 import net.ranides.assira.collection.sets.OpenSet;
 import net.ranides.assira.generic.CompareUtils;
 
@@ -31,7 +32,7 @@ public interface MultiMap<K,V> extends Map<K,V> {
      * Empty MultiMap
      */
     @SuppressWarnings("rawtypes")
-    MultiMap EMPTY = new MapUtils.EmptyMM();
+    MultiMap EMPTY = new EmptyMultiMap();
 
     /**
      * Returns view with all values assocciated with key

+ 153 - 0
assira.core/src/main/java/net/ranides/assira/collection/sets/IntSetUtils.java

@@ -0,0 +1,153 @@
+/*
+ * @author Ranides Atterwim {@literal <ranides@gmail.com>}
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.collection.sets;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.function.IntUnaryOperator;
+import lombok.experimental.UtilityClass;
+import net.ranides.assira.collection.iterators.IntIterator;
+import net.ranides.assira.collection.iterators.IntIteratorUtils;
+import net.ranides.assira.functional.covariant.IntProjectionFunction;
+
+/**
+ * Static methods working with Sets
+ *
+ * @author Ranides Atterwim {@literal <ranides@gmail.com>}
+ */
+@UtilityClass
+public final class IntSetUtils {
+
+    /**
+     * Creates view which transforms values stored inside source set.
+     * Returned view does not support modifications.
+     *
+     * @param set source set
+     * @param function mapping function
+     * @return read-only view
+     */
+    public static IntSet map(IntSet set, IntUnaryOperator function) {
+        return new SetAdapter(set, function);
+    }
+
+    /**
+     * Creates view which transforms values stored inside source set.
+     * Returned view supports modifications: it uses passed projection for conversion in both directions.
+     *
+     * @param set source set
+     * @param function mapping projection
+     * @return mutable view
+     */
+    public static IntSet map(IntSet set, IntProjectionFunction function) {
+        return new SetProjection(set, function);
+    }
+    
+    private static class SetProjection extends AIntSet implements Serializable {
+        
+        private static final long serialVersionUID = 1L;
+        
+        protected final IntSet data;
+        
+        protected final IntProjectionFunction function;
+
+        public SetProjection(IntSet data, IntProjectionFunction function) {
+            this.data = data;
+            this.function = function;
+        }
+
+        @Override
+        public IntIterator iterator() {
+            return IntIteratorUtils.map(data.iterator(), function::applyAsInt);
+        }
+
+        @Override
+        public int size() {
+            return data.size();
+        }
+
+        @Override
+        public boolean remove(Object value) {
+            if(value instanceof Integer) {
+                Object v = function.invert((Integer) value);
+                return data.remove(v);
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public boolean add(int value) {
+            return data.add( function.invert(value) );
+        }
+
+        @Override
+        @SuppressWarnings("unchecked")
+        public boolean contains(Object value) {
+            if(value instanceof Integer) {
+                Object v = function.invert((Integer) value);
+                return data.contains(v);
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public int hashCode() {
+            return this.data.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if(obj instanceof Set) {
+                Set<?> that = (Set<?>)obj;
+                return this.size() == that.size() && this.containsAll(that);
+            }
+            return false;
+        }
+        
+    }
+    
+    private static class SetAdapter extends AIntSet implements Serializable {
+        
+        private static final long serialVersionUID = 1L;
+        
+        protected final IntSet data;
+        
+        protected final IntUnaryOperator function;
+
+        public SetAdapter(IntSet data, IntUnaryOperator function) {
+            this.data = data;
+            this.function = function;
+        }
+
+        @Override
+        public IntIterator iterator() {
+            return IntIteratorUtils.map(data.iterator(), function);
+        }
+
+        @Override
+        public int size() {
+            return data.size();
+        }
+        
+        @Override
+        public int hashCode() {
+            return this.data.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if(obj instanceof Set) {
+                Set<?> that = (Set<?>)obj;
+                return this.size() == that.size() && this.containsAll(that);
+            }
+            return false;
+        }
+
+    }
+
+}

+ 1 - 1
assira.core/src/main/java/net/ranides/assira/reflection/impl/GContext.java

@@ -57,7 +57,7 @@ public class GContext extends AContext implements Serializable {
     @Override
     public Map<String, Type> map() {
         OpenMap<String, Type> map = new OpenMap<>();
-        map.putAll(MapUtils.map(params, c -> c.reflective()));
+        map.putAll(MapUtils.valueAdapter(params, c -> c.reflective()));
         map.putAll(super.map());
         return map;
     }

+ 1 - 1
assira.core/src/main/java/net/ranides/assira/reflection/impl/bean/RBeanModel.java

@@ -111,7 +111,7 @@ public class RBeanModel implements BeanModel, Serializable {
 
     @Override
     public Map<String, Object> properties(Object that) {
-        return MapUtils.mapVV(properties, p -> p.get(that), (p,v) -> p.replace(that, v));
+        return MapUtils.valueDelegate(properties, p -> p.get(that), (p,v) -> p.replace(that, v));
     }
 
     @Override

+ 1 - 1
assira.core/src/main/java/net/ranides/assira/xml/impl/W3Attributes.java

@@ -67,7 +67,7 @@ public class W3Attributes extends CElements {
     
     @Override
     public MultiMap<String, String> map() {
-        return MapUtils.mapKV(map, this::$value, map::putValue);
+        return MapUtils.valueProjection(map, this::$value, map::putValue);
     }
     
     private String $value(Node node) {

+ 5 - 5
assira.core/src/test/java/net/ranides/assira/collection/maps/MapUtilsTest.java

@@ -41,9 +41,9 @@ public class MapUtilsTest {
         Map<Object,?> b = a;
         Map<?,?> c = a;
 
-        Map<String, Number> ma = MapUtils.keymap(a, String::valueOf);
-        Map<String, Object> mb = MapUtils.keymap(b, String::valueOf);
-        Map<String, Object> mc = MapUtils.keymap(c, String::valueOf);
+        Map<String, Number> ma = MapUtils.keyMap(a, String::valueOf);
+        Map<String, Object> mb = MapUtils.keyMap(b, String::valueOf);
+        Map<String, Object> mc = MapUtils.keyMap(c, String::valueOf);
 
         Assert.assertNotNull(ma);
         Assert.assertNotNull(mb);
@@ -57,7 +57,7 @@ public class MapUtilsTest {
         Function<int[], Map<TPoint, Integer>> gf = (Function<int[], Map<TPoint, Integer>> & Serializable)(int[] array) -> {
             Map<TPoint, TWrapper<Integer>> mmap = new OpenMap<>();
             TWrapper.into(mmap, tmap.list(array));
-            return MapUtils.map(mmap, TWrapper.projection());
+            return MapUtils.valueProjection(mmap, TWrapper.projection());
         };
         
         ContractTesters.runner()
@@ -74,7 +74,7 @@ public class MapUtilsTest {
         Function<int[], Map<TPoint, Integer>> gf = (Function<int[], Map<TPoint, Integer>> & Serializable)(int[] array) -> {
             Map<TPoint, TWrapper<Integer>> mmap = new OpenMap<>();
             TWrapper.into(mmap, tmap.list(array));
-            return MapUtils.map(mmap, TWrapper.unwrap());
+            return MapUtils.valueAdapter(mmap, TWrapper.unwrap());
         };
         
         ContractTesters.runner()

+ 1 - 1
assira.core/src/test/java/net/ranides/assira/reflection/impl/bean/ABeanPropertyTest.java

@@ -82,7 +82,7 @@ public class ABeanPropertyTest {
         ForBeanModel bean = new ForBeanModel();
         BeanModel model = BeanModel.typefor(bean);
         
-        Map<String, String> properties = MapUtils.map(model.properties(), p -> p.getClass().getSimpleName());
+        Map<String, String> properties = MapUtils.valueAdapter(model.properties(), p -> p.getClass().getSimpleName());
         assertEquals(PROPERTIES, properties);
     }
     

+ 1 - 1
assira.core/src/test/java/net/ranides/assira/reflection/impl/bean/RBeanModelTest.java

@@ -59,7 +59,7 @@ public class RBeanModelTest {
         ForBeanModel bean = new ForBeanModel();
         BeanModel model = BeanModel.typefor(bean);
 
-        Map<String, String> properties = MapUtils.map(model.methods(), p -> 
+        Map<String, String> properties = MapUtils.valueAdapter(model.methods(), p ->
             p.getClass().getSimpleName() + ":" + p.name()
         );
         assertEquals(METHODS, properties);