@Test void testGetResourcesFromJson() { String json = "[{'id':'idValue1','type':'ENTITY_TYPE_ABSTRACT'},{'id':'idValue2','type':'PACKAGE'}]"; ResourceIdentifier expected1 = ResourceIdentifier.create(ResourceType.ENTITY_TYPE_ABSTRACT, "idValue1"); ResourceIdentifier expected2 = ResourceIdentifier.create(ResourceType.PACKAGE, "idValue2"); List<ResourceIdentifier> expected = newArrayList(expected1, expected2); assertEquals(expected, getResourcesFromJson(json)); }
public static List<ResourceIdentifier> getResourcesFromJson(String resourceJson) { Gson gson = new Gson(); List<ResourceIdentifier> resources = newArrayList(); @SuppressWarnings("unchecked") List<Map<String, String>> jsonList = gson.fromJson(resourceJson, List.class); for (Map<String, String> jsonResource : jsonList) { resources.add( ResourceIdentifier.create( ResourceType.valueOf(jsonResource.get("type")), jsonResource.get("id"))); } return resources; }
ResourceIdentifierUtil { public static List<ResourceIdentifier> getResourcesFromJson(String resourceJson) { Gson gson = new Gson(); List<ResourceIdentifier> resources = newArrayList(); @SuppressWarnings("unchecked") List<Map<String, String>> jsonList = gson.fromJson(resourceJson, List.class); for (Map<String, String> jsonResource : jsonList) { resources.add( ResourceIdentifier.create( ResourceType.valueOf(jsonResource.get("type")), jsonResource.get("id"))); } return resources; } }
ResourceIdentifierUtil { public static List<ResourceIdentifier> getResourcesFromJson(String resourceJson) { Gson gson = new Gson(); List<ResourceIdentifier> resources = newArrayList(); @SuppressWarnings("unchecked") List<Map<String, String>> jsonList = gson.fromJson(resourceJson, List.class); for (Map<String, String> jsonResource : jsonList) { resources.add( ResourceIdentifier.create( ResourceType.valueOf(jsonResource.get("type")), jsonResource.get("id"))); } return resources; } private  ResourceIdentifierUtil(); }
ResourceIdentifierUtil { public static List<ResourceIdentifier> getResourcesFromJson(String resourceJson) { Gson gson = new Gson(); List<ResourceIdentifier> resources = newArrayList(); @SuppressWarnings("unchecked") List<Map<String, String>> jsonList = gson.fromJson(resourceJson, List.class); for (Map<String, String> jsonResource : jsonList) { resources.add( ResourceIdentifier.create( ResourceType.valueOf(jsonResource.get("type")), jsonResource.get("id"))); } return resources; } private  ResourceIdentifierUtil(); static List<ResourceIdentifier> getResourcesFromJson(String resourceJson); }
ResourceIdentifierUtil { public static List<ResourceIdentifier> getResourcesFromJson(String resourceJson) { Gson gson = new Gson(); List<ResourceIdentifier> resources = newArrayList(); @SuppressWarnings("unchecked") List<Map<String, String>> jsonList = gson.fromJson(resourceJson, List.class); for (Map<String, String> jsonResource : jsonList) { resources.add( ResourceIdentifier.create( ResourceType.valueOf(jsonResource.get("type")), jsonResource.get("id"))); } return resources; } private  ResourceIdentifierUtil(); static List<ResourceIdentifier> getResourcesFromJson(String resourceJson);  }