From 295c0dfc73ce9cd29916fba2c03004a5b919c646 Mon Sep 17 00:00:00 2001 From: Munir Ahmad Date: Fri, 9 Mar 2018 19:59:34 -0500 Subject: Swap Optional.isPresent with functional expression Change-Id: Id4b724b189f98c89e3e038b154990a95733e0624 Issue-ID: SO-437 Signed-off-by: Munir Ahmad --- .../main/java/org/openecomp/mso/client/policy/RestClient.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'bpmn/MSOCommonBPMN') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java index 74b1c3f802..1436d83a94 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java @@ -157,14 +157,9 @@ public abstract class RestClient { } client.register(this.getMapper()); Optional responseFilter = this.addResponseFilter(); - if (responseFilter.isPresent()) { - client.register(responseFilter.get()); - } - if (!path.isPresent()) { - webTarget = client.target(host.toString()); - } else { - webTarget = client.target(UriBuilder.fromUri(host + path.get().toString())); - } + responseFilter.ifPresent(clientResponseFilter -> client.register(clientResponseFilter)); + webTarget = path.map(uri -> client.target(UriBuilder.fromUri(host + uri.toString()))) + .orElseGet(() -> client.target(host.toString())); this.accept = MediaType.APPLICATION_JSON; this.contentType = MediaType.APPLICATION_JSON; } -- cgit 1.2.3-korg