From da9a362382e3229ddcaa86fd91ac695a1914ebef Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 25 Sep 2018 13:03:21 +0100 Subject: Fix sonar issues in Command line editor THe Apex command line editor had issues in teh way its loops for processing commands were written. The loops are simplified in this review. Issue-ID: POLICY-1034 Change-Id: If684a57de79bd56211e1ca3e8c446bd9698666be Signed-off-by: liamfallon --- .../policy/apex/model/modelapi/ApexApiResult.java | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'model/model-api') diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java index ae2609e1d..ddd46c879 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java @@ -70,7 +70,25 @@ public class ApexApiResult { * The method call failed for another reason such as the method call is not implemented yet * on the concept on which it was called. */ - OTHER_ERROR + OTHER_ERROR; + + /** + * Check if a result is OK. + * + * @return true if the result is not OK + */ + public static boolean isOk(final Result result) { + return result == Result.SUCCESS || result == Result.FINISHED; + } + + /** + * Check if a result is not OK. + * + * @return true if the result is not OK + */ + public static boolean isNok(final Result result) { + return !isOk(result); + } } private Result result; @@ -139,7 +157,7 @@ public class ApexApiResult { */ @XmlAttribute(required = true) public boolean isOk() { - return result == Result.SUCCESS || result == Result.FINISHED; + return Result.isOk(result); } /** @@ -149,7 +167,7 @@ public class ApexApiResult { * @return true, if the result indicates the API operation did not succeed */ public boolean isNok() { - return !isOk(); + return Result.isNok(result); } /** -- cgit 1.2.3-korg