TypeUtils { static Map.Entry<String,Object> parse(String label, JsonElement element) { final String name; final String typeName; int colonIndex = label.indexOf(":"); if (colonIndex < 0) { name = label; typeName = null; } else { name = label.substring(0, colonIndex); typeName = label.substring(colonIndex + 1); } Type<?> type = findType(typeName); return new MapEntry<String, Object>(name, type.parse(element)); }    }
@Test(expected = IllegalArgumentException.class) public void testInvalidType1() throws Exception { String label = "foo:Float:"; JsonObject root = gson.fromJson(String.format("{ '%s' : 123 }", label), JsonObject.class); TypeUtils.parse(label, root.get(label)); }
@Test(expected = IllegalArgumentException.class) public void testInvalidType2() throws Exception { String label = "foo:"; JsonObject root = gson.fromJson(String.format("{ '%s' : 123 }", label), JsonObject.class); TypeUtils.parse(label, root.get(label)); }