@Test @SuppressWarnings("unchecked") public void testWritableMap() { final Map<String, String> map = SplitMapUtils.writableMap(transformedMap); attemptGetOperation(new Runnable() { public void run() { map.get(null); } }); attemptGetOperation(new Runnable() { public void run() { map.entrySet(); } }); attemptGetOperation(new Runnable() { public void run() { map.keySet(); } }); attemptGetOperation(new Runnable() { public void run() { map.values(); } }); attemptGetOperation(new Runnable() { public void run() { map.size(); } }); attemptGetOperation(new Runnable() { public void run() { map.isEmpty(); } }); attemptGetOperation(new Runnable() { public void run() { map.containsKey(null); } }); attemptGetOperation(new Runnable() { public void run() { map.containsValue(null); } }); attemptGetOperation(new Runnable() { public void run() { map.remove(null); } }); final Map<String, String> other = SplitMapUtils.writableMap(transformedMap); assertEquals(other, map); assertEquals(other.hashCode(), map.hashCode()); int sz = backingMap.size(); assertFalse(backingMap.containsKey("foo")); map.put("new", "66"); assertEquals(++sz, backingMap.size()); final Map<String, String> more = new HashMap<String, String>(); more.put("foo", "77"); more.put("bar", "88"); more.put("baz", "99"); map.putAll(more); assertEquals(sz + more.size(), backingMap.size()); map.clear(); assertTrue(backingMap.isEmpty()); assertSame(map, SplitMapUtils.writableMap((Put<String, String>) map)); }
@SuppressWarnings("unchecked") public static <K, V> Map<K, V> writableMap(final Put<K, V> put) { if (put == null) { throw new NullPointerException("Put must not be null"); } if (put instanceof Map) { return (Map<K, V>) put; } return new WrappedPut<K, V>(put); }
SplitMapUtils { @SuppressWarnings("unchecked") public static <K, V> Map<K, V> writableMap(final Put<K, V> put) { if (put == null) { throw new NullPointerException("Put must not be null"); } if (put instanceof Map) { return (Map<K, V>) put; } return new WrappedPut<K, V>(put); } }
SplitMapUtils { @SuppressWarnings("unchecked") public static <K, V> Map<K, V> writableMap(final Put<K, V> put) { if (put == null) { throw new NullPointerException("Put must not be null"); } if (put instanceof Map) { return (Map<K, V>) put; } return new WrappedPut<K, V>(put); } private  SplitMapUtils(); }
SplitMapUtils { @SuppressWarnings("unchecked") public static <K, V> Map<K, V> writableMap(final Put<K, V> put) { if (put == null) { throw new NullPointerException("Put must not be null"); } if (put instanceof Map) { return (Map<K, V>) put; } return new WrappedPut<K, V>(put); } private  SplitMapUtils(); @SuppressWarnings("unchecked") static IterableMap<K, V> readableMap(final Get<K, V> get); @SuppressWarnings("unchecked") static Map<K, V> writableMap(final Put<K, V> put); }
SplitMapUtils { @SuppressWarnings("unchecked") public static <K, V> Map<K, V> writableMap(final Put<K, V> put) { if (put == null) { throw new NullPointerException("Put must not be null"); } if (put instanceof Map) { return (Map<K, V>) put; } return new WrappedPut<K, V>(put); } private  SplitMapUtils(); @SuppressWarnings("unchecked") static IterableMap<K, V> readableMap(final Get<K, V> get); @SuppressWarnings("unchecked") static Map<K, V> writableMap(final Put<K, V> put);  }