From eaf3700274cb29669ac0c4260ceb5d45160e7815 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 10 Oct 2018 18:01:49 +0200 Subject: [PATCH] Refactoring Annotated AsyncCallback as FunctionalInterface Removed redundant local variable Changed ApiEnvironment.fromValue(String) --- .../java/com/microsoft/bingads/ApiEnvironment.java | 10 ++++------ src/main/java/com/microsoft/bingads/AsyncCallback.java | 1 + src/main/java/com/microsoft/bingads/ServiceClient.java | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/microsoft/bingads/ApiEnvironment.java b/src/main/java/com/microsoft/bingads/ApiEnvironment.java index 428d46d126..1bbfbccdea 100644 --- a/src/main/java/com/microsoft/bingads/ApiEnvironment.java +++ b/src/main/java/com/microsoft/bingads/ApiEnvironment.java @@ -1,5 +1,7 @@ package com.microsoft.bingads; +import java.util.Arrays; + /** * Represents Bing Ads API environment (Production or Sandbox). */ @@ -26,11 +28,7 @@ public String value() { } public static ApiEnvironment fromValue(String v) { - for (ApiEnvironment c : ApiEnvironment.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); + return Arrays.stream(values()).filter((env) -> env.value.equals(v)).findFirst() + .orElseThrow(() -> new IllegalArgumentException(v)); } } diff --git a/src/main/java/com/microsoft/bingads/AsyncCallback.java b/src/main/java/com/microsoft/bingads/AsyncCallback.java index 7bd6a310d3..ed09075c81 100644 --- a/src/main/java/com/microsoft/bingads/AsyncCallback.java +++ b/src/main/java/com/microsoft/bingads/AsyncCallback.java @@ -7,6 +7,7 @@ * * @param the type of result */ +@FunctionalInterface public interface AsyncCallback { /** diff --git a/src/main/java/com/microsoft/bingads/ServiceClient.java b/src/main/java/com/microsoft/bingads/ServiceClient.java index d0090d15df..ec35da3ae2 100644 --- a/src/main/java/com/microsoft/bingads/ServiceClient.java +++ b/src/main/java/com/microsoft/bingads/ServiceClient.java @@ -140,9 +140,7 @@ public List getHandlerChain(PortInfo portInfo) { } }); - T port = serviceFactory.createProxyFromService(service, environment, serviceInterface); - - return port; + return serviceFactory.createProxyFromService(service, environment, serviceInterface); } private void refreshOAuthTokensIfNeeded() {