From 231bc997e100c502080dfb903b3e507771aa7456 Mon Sep 17 00:00:00 2001 From: Bharat saraswal Date: Fri, 22 Sep 2017 20:10:31 +0530 Subject: Resolved below sonar issues. uncessary use of string builder removed. removed redundant code. rename variable to follow camelCase. removed tab char and changed them with spaces. Issue-ID:SO-98 Change-Id: Idbeed60ebc843c91a89fdd9357330e5e093172c6 Signed-off-by: Bharat saraswal --- .../woorea/openstack/nova/api/FlavorsResource.java | 140 ++++++++++----------- 1 file changed, 69 insertions(+), 71 deletions(-) (limited to 'nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java') diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java index c3e2256..0c8621d 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java @@ -10,76 +10,74 @@ import com.woorea.openstack.nova.model.Flavors; import com.woorea.openstack.nova.model.Metadata; public class FlavorsResource { - - private final OpenStackClient CLIENT; - - public FlavorsResource(OpenStackClient client) { - CLIENT = client; - } - - public List list(boolean detail) { - return new List(detail); - } - - public Create create(Flavor flavor) { - return new Create(flavor); - } - - public Show show(String id) { - return new Show(id); - } - - public ShowMetadata showMetadata(String id) { - return new ShowMetadata(id); - } - - - public Delete delete(String id) { - return new Delete(id); - } - - public class List extends OpenStackRequest { - - public List(boolean detail) { - super(CLIENT, HttpMethod.GET, detail ? "/flavors/detail" : "/flavors", null, Flavors.class); - } - - } - - public class Create extends OpenStackRequest { - - private Flavor flavor; - - public Create(Flavor flavor) { - super(CLIENT, HttpMethod.POST, "/flavors", Entity.json(flavor), Flavor.class); - this.flavor = flavor; - } - - } - - public class Show extends OpenStackRequest { - - public Show(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/flavors/").append(id).toString(), null, Flavor.class); - } - - } - - public class ShowMetadata extends OpenStackRequest { - - public ShowMetadata(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/flavors/").append(id).append("/metadata").toString(), null, Metadata.class); - } - - } - - public class Delete extends OpenStackRequest { - - public Delete(String id) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/flavors/").append(id).toString(), null, Void.class); - } - - } - + + private final OpenStackClient client; + + public FlavorsResource(OpenStackClient client) { + this.client = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public Create create(Flavor flavor) { + return new Create(flavor); + } + + public Show show(String id) { + return new Show(id); + } + + public ShowMetadata showMetadata(String id) { + return new ShowMetadata(id); + } + + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest { + + public List(boolean detail) { + super(client, HttpMethod.GET, detail ? "/flavors/detail" : "/flavors", null, Flavors.class); + } + } + + public class Create extends OpenStackRequest { + + private Flavor flavor; + + public Create(Flavor flavor) { + super(client, HttpMethod.POST, "/flavors", Entity.json(flavor), Flavor.class); + this.flavor = flavor; + } + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(client, HttpMethod.GET, getFlavorsString(id), null, Flavor.class); + } + } + + public class ShowMetadata extends OpenStackRequest { + + public ShowMetadata(String id) { + super(client, HttpMethod.GET, "/flavors/" + id + "/metadata", null, Metadata.class); + } + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(client, HttpMethod.DELETE, getFlavorsString(id), null, Void.class); + } + } + + private String getFlavorsString(String id) { + return "/flavors/" + id; + } } -- cgit 1.2.3-korg