Use getId() convenience method in Cloud Foundry ServiceInfoCreators to reduce duplication.
This commit is contained in:
@@ -20,7 +20,7 @@ public class AmqpServiceInfoCreator extends CloudFoundryServiceInfoCreator<AmqpS
|
||||
public AmqpServiceInfo createServiceInfo(Map<String,Object> serviceData) {
|
||||
Map<String,Object> credentials = getCredentials(serviceData);
|
||||
|
||||
String id = (String) serviceData.get("name");
|
||||
String id = getId(serviceData);
|
||||
|
||||
String uri = getUriFromCredentials(credentials);
|
||||
String managementUri = getStringFromCredentials(credentials, "http_api_uri");
|
||||
|
||||
@@ -70,6 +70,10 @@ public abstract class CloudFoundryServiceInfoCreator<SI extends ServiceInfo> imp
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getId(Map<String, Object> serviceData) {
|
||||
return (String) serviceData.get("name");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Map<String, Object> getCredentials(Map<String, Object> serviceData) {
|
||||
return (Map<String, Object>) serviceData.get("credentials");
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MongoServiceInfoCreator extends CloudFoundryServiceInfoCreator<Mong
|
||||
}
|
||||
|
||||
public MongoServiceInfo createServiceInfo(Map<String,Object> serviceData) {
|
||||
String id = (String) serviceData.get("name");
|
||||
String id = getId(serviceData);
|
||||
|
||||
String uri = getUriFromCredentials(getCredentials(serviceData));
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MonitoringServiceInfoCreator extends CloudFoundryServiceInfoCreator
|
||||
|
||||
@Override
|
||||
public MonitoringServiceInfo createServiceInfo(Map<String, Object> serviceData) {
|
||||
String id = (String) serviceData.get("name");
|
||||
String id = getId(serviceData);
|
||||
return new MonitoringServiceInfo(id);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class RedisServiceInfoCreator extends CloudFoundryServiceInfoCreator<Redi
|
||||
}
|
||||
|
||||
public RedisServiceInfo createServiceInfo(Map<String,Object> serviceData) {
|
||||
String id = (String) serviceData.get("name");
|
||||
String id = getId(serviceData);
|
||||
|
||||
Map<String, Object> credentials = getCredentials(serviceData);
|
||||
String uri = getUriFromCredentials(credentials);
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class RelationalServiceInfoCreator<SI extends RelationalServiceI
|
||||
public abstract SI createServiceInfo(String id, String uri);
|
||||
|
||||
public SI createServiceInfo(Map<String, Object> serviceData) {
|
||||
String id = (String) serviceData.get("name");
|
||||
String id = getId(serviceData);
|
||||
|
||||
Map<String,Object> credentials = getCredentials(serviceData);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SmtpServiceInfoCreator extends CloudFoundryServiceInfoCreator<SmtpS
|
||||
}
|
||||
|
||||
public SmtpServiceInfo createServiceInfo(Map<String, Object> serviceData) {
|
||||
String id = (String) serviceData.get("name");
|
||||
String id = getId(serviceData);
|
||||
|
||||
Map<String, Object> credentials = getCredentials(serviceData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user