public static @Nullable List<Map<String, Object>> getListOfMaps(
      Map<String, Object> map, String name, @Nullable List<Map<String, Object>> defaultValue) {
    @Nullable Object value = map.get(name);
    if (value == null) {
      if (map.containsKey(name)) {
        throw new IncorrectTypeException(name, map, "a list");
      }
      return defaultValue;
    }
    if (Data.isNull(value)) {
      // This is a JSON literal null.  When represented as a list,
      // this is an empty list.
      return Collections.emptyList();
    }

    if (!(value instanceof List)) {
      throw new IncorrectTypeException(name, map, "a list");
    }

    List<?> elements = (List<?>) value;
    for (Object elem : elements) {
      if (!(elem instanceof Map)) {
        throw new IncorrectTypeException(name, map, "a list of Map objects");
      }
    }

    @SuppressWarnings("unchecked")
    List<Map<String, Object>> result = (List<Map<String, Object>>) elements;
    return result;
  }
@Test
  public void testGetListOfMaps() throws Exception {
    Map<String, Object> o = makeCloudDictionary();

    Assert.assertEquals(makeCloudObjects(), getListOfMaps(o, "multipleObjectsKey", null));

    try {
      getListOfMaps(o, "singletonLongKey", null);
      Assert.fail("should have thrown an exception");
    } catch (Exception exn) {
      assertThat(exn.toString(), Matchers.containsString("not a list"));
    }
  }