Here you can find the source of integerToStrBool(Integer integer)
Parameter | Description |
---|---|
integer | Could be any value including null , but should be either 0 or 1 |
public static String integerToStrBool(Integer integer)
//package com.java2s; /*/*from w ww . j av a 2s .com*/ * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see http://www.gnu.org/licenses/ */ public class Main { private static final String YES = "Yes"; private static final String NO = "No"; private static final String NA = "N/A"; /** * Converts an integer to a human readable boolean. * * @param integer Could be any value including {@code null}, but should be either 0 or 1 * @return "No" for "0", "Yes" for "1", an empty string for null, and "N/A" in all other cases */ public static String integerToStrBool(Integer integer) { if (integer == null) { return ""; } if (integer == 0) { return NO; } else if (integer == 1) { return YES; } else { return NA; } } }