X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Flayer%2FResult.java;h=9050553c67a8987b58aa468d95229f86b0407bbb;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=3e68e3abcd167dcdc502eab1b0ee10866d38d712;hpb=7bc90216b56c9a4c1de4482854b9b56c22bc36c8;p=aaf%2Fauthz.git diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java index 3e68e3ab..9050553c 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,13 +28,13 @@ import java.util.Set; /** * It would be nice if Java Enums were extensible, but they're not. - * + * * @author Jonathan * */ public class Result { private static final String SUCCESS = "Success"; - public static final String[] EMPTY_VARS = new String[0]; + public static final Object[] EMPTY_VARS = new Object[0]; public final static int OK=0, ERR_Security = 1, @@ -47,13 +47,13 @@ public class Result { ERR_ActionNotCompleted = 8, ERR_Backend = 9, ERR_General = 20; - + public RV value; public final int status; public final String details; - public final String[] variables; - - public Result(RV value, int status, String details, String[] variables) { + public final Object[] variables; + + public Result(RV value, int status, String details, Object ... variables) { this.value = value; if (value==null) { specialCondition|=EMPTY_LIST; @@ -66,18 +66,18 @@ public class Result { this.variables=variables; } } - + /** * Create a Result class with "OK" status and "Success" for details - * + * * This is the easiest to use - * + * * @param value * @param status * @return */ public static Result ok(R value) { - return new Result(value,OK,SUCCESS,null); + return new Result(value,OK,SUCCESS,EMPTY_VARS); } /** @@ -86,7 +86,7 @@ public class Result { * @return */ public static Result ok(R value[]) { - return new Result(value,OK,SUCCESS,null).emptyList(value.length==0); + return new Result(value,OK,SUCCESS,EMPTY_VARS).emptyList(value.length==0); } /** @@ -95,7 +95,7 @@ public class Result { * @return */ public static Result> ok(Set value) { - return new Result>(value,OK,SUCCESS,null).emptyList(value.size()==0); + return new Result>(value,OK,SUCCESS,EMPTY_VARS).emptyList(value.size()==0); } /** @@ -104,7 +104,7 @@ public class Result { * @return */ public static Result> ok(List value) { - return new Result>(value,OK,SUCCESS,null).emptyList(value.size()==0); + return new Result>(value,OK,SUCCESS,EMPTY_VARS).emptyList(value.size()==0); } /** @@ -113,7 +113,7 @@ public class Result { * @return */ public static Result> ok(Collection value) { - return new Result>(value,OK,SUCCESS,null).emptyList(value.size()==0); + return new Result>(value,OK,SUCCESS,EMPTY_VARS).emptyList(value.size()==0); } @@ -122,11 +122,11 @@ public class Result { * @return */ public static Result ok() { - return new Result(null,OK,SUCCESS,null); + return new Result(null,OK,SUCCESS,EMPTY_VARS); } /** - * Create a Status (usually non OK, with a details statement + * Create a Status (usually non OK, with a details statement * @param value * @param status * @param details @@ -135,7 +135,7 @@ public class Result { // public static Result err(int status, String details) { // return new Result(null,status,details,null); // } - + /** * Create a Status (usually non OK, with a details statement and variables supported * @param status @@ -143,7 +143,7 @@ public class Result { * @param variables * @return */ - public static Result err(int status, String details, String ... variables) { + public static Result err(int status, String details, Object ... variables) { return new Result(null,status,details,variables); } @@ -166,18 +166,18 @@ public class Result { } /** - * Create a Status (usually non OK, with a details statement + * Create a Status (usually non OK, with a details statement * @param value * @param status * @param details * @return */ - public static Result create(R value, int status, String details, String ... vars) { + public static Result create(R value, int status, String details, Object ... vars) { return new Result(value,status,details,vars); } /** - * Create a Status from a previous status' result/details + * Create a Status from a previous status' result/details * @param value * @param status * @param details @@ -189,10 +189,10 @@ public class Result { private static final int PARTIAL_CONTENT = 0x001; private static final int EMPTY_LIST = 0x002; - + /** - * AAF Specific problems, etc - * + * AAF Specific problems, etc + * * @author Jonathan * */ @@ -227,7 +227,7 @@ public class Result { /** * When Result is a List, you can check here to see if it's empty instead of looping - * + * * @return */ public boolean isEmpty() { @@ -237,7 +237,7 @@ public class Result { /** * A common occurrence is that data comes back, but list is empty. If set, you can skip looking * at list at the outset. - * + * * @param emptyList * @return */ @@ -250,8 +250,8 @@ public class Result { return this; } - - /** + + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -260,7 +260,7 @@ public class Result { return status == OK; } - /** + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -269,19 +269,17 @@ public class Result { return status != OK; } - /** + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return */ public boolean isOKhasData() { - System.out.println("specialCondition:"+specialCondition); - System.out.println("specialCondition:"+(specialCondition & EMPTY_LIST)); return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST; } - /** + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -309,7 +307,7 @@ public class Result { return sb.toString(); } } - + public String errorString() { StringBuilder sb = new StringBuilder(); switch(status) { @@ -324,7 +322,7 @@ public class Result { default: sb.append("Error"); } sb.append(" - "); - sb.append(String.format(details, (Object[])variables)); + sb.append(String.format(details, variables)); return sb.toString(); } }