@@ -0,0 +1,2279 @@
+/*%0A * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.b2international.commons;%0A%0A/**%0A * Utility class for booleans%0A * %0A */%0Apublic final class BooleanUtils %7B%0A%0A%09/**%0A%09 * Converts a primitive integer to boolean by assuming 0 is false and everything else (1) is true.%0A%09 * %0A%09 * @param number%0A%09 * @return %3Ccode%3Etrue%3C/code%3E or %3Ccode%3Efalse%3C/code%3E based on the input%0A%09 */%0A%09public static boolean valueOf(int number) %7B%0A%09%09return 0 == number ? false : true;%0A%09%7D%0A%0A%09/**%0A%09 * Converts an %7B@link Integer%7D object to %7B@link Boolean%7D by assuming 0 is false and everything else (1) is true. If the parameter is%0A%09 * %3Ccode%3Enull%3C/code%3E then it returns %3Ccode%3Enull%3C/code%3E.%0A%09 * %0A%09 * @param value%0A%09 * @return %3Ccode%3Enull%3C/code%3E if the parameter is %3Ccode%3Enull%3C/code%3E, %3Ccode%3Etrue%3C/code%3E or %3Ccode%3Efalse%3C/code%3E otherwise.%0A%09 */%0A%09public static Boolean valueOf(Integer value) %7B%0A%09%09if (null == value) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09return 0 == value.intValue() ? Boolean.FALSE : Boolean.TRUE;%0A%09%7D%0A%0A%09/**%0A%09 * Converts a primitive boolean to a primitive integer by assuming 0 is false and everything else (1) is true.%0A%09 * %0A%09 * @param bool%0A%09 * @return 0 if the parameter is false, 1 otherwise.%0A%09 */%0A%09public static int toInteger(boolean bool) %7B%0A%09%09return bool ? 1 : 0;%0A%09%7D%0A%0A%09/**%0A%09 * Converts a %7B@link Boolean%7D object to an %7B@link Integer%7D by assuming 0 is false and everything else (1) is true. If the parameter is%0A%09 * %3Ccode%3Enull%3C/code%3E then it returns %3Ccode%3Enull%3C/code%3E.%0A%09 * %0A%09 * @param bool%0A%09 * @return %3Ccode%3Enull%3C/code%3E if the parameter is %3Ccode%3Enull%3C/code%3E, 0 if false, 1 if true.%0A%09 */%0A%09public static Integer toInteger(Boolean bool) %7B%0A%09%09if (null == bool) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09return bool.booleanValue() ? new Integer(1) : new Integer(0);%0A%09%7D%0A%7D%0A

Introduce util class for booleans