@SuppressWarnings("unchecked")
private CloudServiceInstance mapServiceInstanceResource(Map<String, Object> resource) {
CloudServiceInstance serviceInstance = new CloudServiceInstance(getV2Meta(resource), getNameOfV2Resource(resource));
serviceInstance.setType(getAttributeOfV2Resource(resource, "type", String.class));
serviceInstance.setDashboardUrl(getAttributeOfV2Resource(resource, "dashboard_url", String.class));
serviceInstance.setCredentials(getAttributeOfV2Resource(resource, "credentials", Map.class));
Map<String, Object> servicePlanResource = getEmbeddedResource(resource, "service_plan");
if (servicePlanResource != null) {
serviceInstance.setServicePlan(mapServicePlanResource(servicePlanResource));
}
CloudService service = mapServiceResource(resource);
serviceInstance.setService(service);
List<Map<String, Object>> bindingsResource = getEmbeddedResourceList(getEntity(resource), "service_bindings");
List<CloudServiceBinding> bindings = new ArrayList<>(bindingsResource.size());
for (Map<String, Object> bindingResource : bindingsResource) {
bindings.add(mapServiceBinding(bindingResource));
}
serviceInstance.setBindings(bindings);
return serviceInstance;
}