@Test public void testPutAll() { Map<String, Object> testData = Maps.newHashMap(); String keyString1 = "string1"; String valueString1 = "bar"; testData.put(keyString1, valueString1); String keyString2 = "string1"; String valueString2 = "bar"; testData.put(keyString2, valueString2); String keyInteger = "integer"; int valueInteger = 1; testData.put(keyInteger, valueInteger); String keyDouble = "double"; double valueDouble = 1.23456; testData.put(keyDouble, valueDouble); String keyBoolean = "boolean"; boolean valueBoolean = true; testData.put(keyBoolean, valueBoolean); builder.putAll(testData); Map<String, Object> object = builder.build(); assertEquals(valueString1, object.get(keyString1)); assertEquals(valueString2, object.get(keyString2)); assertEquals(valueInteger, object.get(keyInteger)); assertEquals(valueDouble, object.get(keyDouble)); assertEquals(valueBoolean, object.get(keyBoolean)); }
@Override public JsonBuilder putAll(Map<String, Object> data) { if (currentType == JsonType.OBJECT) { currentObject.putAll(data); } else { throw new JsonInteractiveSpacesException("Cannot put a map of values into an array"); } return this; }
StandardJsonBuilder implements JsonBuilder { @Override public JsonBuilder putAll(Map<String, Object> data) { if (currentType == JsonType.OBJECT) { currentObject.putAll(data); } else { throw new JsonInteractiveSpacesException("Cannot put a map of values into an array"); } return this; } }
StandardJsonBuilder implements JsonBuilder { @Override public JsonBuilder putAll(Map<String, Object> data) { if (currentType == JsonType.OBJECT) { currentObject.putAll(data); } else { throw new JsonInteractiveSpacesException("Cannot put a map of values into an array"); } return this; } StandardJsonBuilder(); }
StandardJsonBuilder implements JsonBuilder { @Override public JsonBuilder putAll(Map<String, Object> data) { if (currentType == JsonType.OBJECT) { currentObject.putAll(data); } else { throw new JsonInteractiveSpacesException("Cannot put a map of values into an array"); } return this; } StandardJsonBuilder(); @Override JsonBuilder put(String name, Object value); @Override JsonBuilder putAll(Map<String, Object> data); @Override JsonBuilder put(Object value); @Override JsonBuilder newObject(String name); @Override JsonBuilder newArray(String name); @Override JsonBuilder newArray(); @Override JsonBuilder newObject(); @Override @SuppressWarnings("unchecked") JsonBuilder up(); @Override Map<String, Object> build(); @Override String toString(); }
StandardJsonBuilder implements JsonBuilder { @Override public JsonBuilder putAll(Map<String, Object> data) { if (currentType == JsonType.OBJECT) { currentObject.putAll(data); } else { throw new JsonInteractiveSpacesException("Cannot put a map of values into an array"); } return this; } StandardJsonBuilder(); @Override JsonBuilder put(String name, Object value); @Override JsonBuilder putAll(Map<String, Object> data); @Override JsonBuilder put(Object value); @Override JsonBuilder newObject(String name); @Override JsonBuilder newArray(String name); @Override JsonBuilder newArray(); @Override JsonBuilder newObject(); @Override @SuppressWarnings("unchecked") JsonBuilder up(); @Override Map<String, Object> build(); @Override String toString();  }