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/ImagesResource.java | 141 ++++++++++----------- 1 file changed, 70 insertions(+), 71 deletions(-) (limited to 'nova-client/src/main/java/com/woorea/openstack/nova/api/ImagesResource.java') diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/ImagesResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/ImagesResource.java index 780cb12..764a845 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/ImagesResource.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/ImagesResource.java @@ -10,76 +10,75 @@ import com.woorea.openstack.nova.model.Images; import com.woorea.openstack.nova.model.Metadata; public class ImagesResource { - - private final OpenStackClient CLIENT; - - public ImagesResource(OpenStackClient client) { - CLIENT = client; - } - - public List list(boolean detail) { - return new List(detail); - } - - public Create create(Image image) { - return new Create(image); - } - - 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 ? "/images/detail" : "/images", null, Images.class); - } - - } - - public class Create extends OpenStackRequest { - - private Image image; - - public Create(Image image) { - super(CLIENT, HttpMethod.POST, "/images", Entity.json(image), Image.class); - this.image = image; - } - - } - - public class Show extends OpenStackRequest { - - public Show(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/images/").append(id).toString(), null, Image.class); - } - - } - - public class ShowMetadata extends OpenStackRequest { - - public ShowMetadata(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/images/").append(id).append("/metadata").toString(), null, Metadata.class); - } - - } - - public class Delete extends OpenStackRequest { - - public Delete(String id) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/images/").append(id).toString(), null, Void.class); - } - - } - + + private final OpenStackClient client; + + public ImagesResource(OpenStackClient client) { + this.client = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public Create create(Image image) { + return new Create(image); + } + + 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 ? "/images/detail" : "/images", null, Images.class); + } + } + + public class Create extends OpenStackRequest { + + private Image image; + + public Create(Image image) { + super(client, HttpMethod.POST, "/images", Entity.json(image), Image.class); + this.image = image; + } + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(client, HttpMethod.GET, getImagesString(id), null, Image.class); + } + } + + public class ShowMetadata extends OpenStackRequest { + + public ShowMetadata(String id) { + super(client, HttpMethod.GET, "/images/" + id + "/metadata", null, + Metadata.class); + } + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(client, HttpMethod.DELETE, getImagesString(id), null, Void.class); + } + } + + private String getImagesString(String id) { + return "/images/" + id; + } } -- cgit 1.2.3-korg