Created
July 6, 2017 06:49
-
-
Save Satomaru/245d835a80959fb4c6c9ae26e57791e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class MapLists<K, V> { | |
public final class Maps { | |
private final HashMap<K, V> map = new HashMap<K, V>(); | |
private Maps() { | |
} | |
public Maps put(K key, V value) { | |
map.put(key, value); | |
return this; | |
} | |
public MapLists<K, V> end() { | |
list.add((unmodifiable) ? Collections.unmodifiableMap(map) : map); | |
return MapLists.this; | |
} | |
} | |
public static <K, V> MapLists<K, V> begin(boolean unmodifiable) { | |
return new MapLists<K, V>(unmodifiable); | |
} | |
private final List<Map<K, V>> list = new ArrayList<Map<K, V>>(); | |
private final boolean unmodifiable; | |
private MapLists(boolean unmodifiable) { | |
this.unmodifiable = unmodifiable; | |
} | |
public Maps row() { | |
return new Maps(); | |
} | |
public List<Map<K, V>> end() { | |
return (unmodifiable) ? Collections.unmodifiableList(list) : list; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment