From f51f6da7319787348c38b875652b5c0e9f88c8aa Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:43:13 -0400 Subject: Cleanup pass Pass to do some cleanups --- src/main/java/bjc/funcdata/FunctionalMap.java | 44 ++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'src/main/java/bjc/funcdata/FunctionalMap.java') diff --git a/src/main/java/bjc/funcdata/FunctionalMap.java b/src/main/java/bjc/funcdata/FunctionalMap.java index fc53829..aba3dd1 100644 --- a/src/main/java/bjc/funcdata/FunctionalMap.java +++ b/src/main/java/bjc/funcdata/FunctionalMap.java @@ -14,10 +14,10 @@ import bjc.data.IPair; * @author ben * * @param - * The type of the map's keys. + * The type of the map's keys. * * @param - * The type of the map's values. + * The type of the map's values. */ public class FunctionalMap implements IMap { /* Our backing store. */ @@ -32,13 +32,13 @@ public class FunctionalMap implements IMap... entries) { this(); - for(final IPair entry : entries) { + for (final IPair entry : entries) { entry.doWith((key, val) -> { wrappedMap.put(key, val); }); @@ -49,10 +49,11 @@ public class FunctionalMap implements IMap wrap) { - if(wrap == null) throw new NullPointerException("Map to wrap must not be null"); + if (wrap == null) + throw new NullPointerException("Map to wrap must not be null"); wrappedMap = wrap; } @@ -89,9 +90,10 @@ public class FunctionalMap implements IMap implements IMap IMap transform(final Function transformer) { - if(transformer == null) throw new NullPointerException("Transformer must not be null"); + public IMap + transform(final Function transformer) { + if (transformer == null) + throw new NullPointerException("Transformer must not be null"); return new TransformedValueMap<>(this, transformer); } @Override public ValueType put(final KeyType key, final ValueType val) { - if(key == null) throw new NullPointerException("Key must not be null"); + if (key == null) + throw new NullPointerException("Key must not be null"); return wrappedMap.put(key, val); } @@ -161,15 +166,20 @@ public class FunctionalMap implements IMap other = (FunctionalMap) obj; - if(wrappedMap == null) { - if(other.wrappedMap != null) return false; - } else if(!wrappedMap.equals(other.wrappedMap)) return false; + if (wrappedMap == null) { + if (other.wrappedMap != null) + return false; + } else if (!wrappedMap.equals(other.wrappedMap)) + return false; return true; } } -- cgit v1.2.3