| 200 | } |
| 201 | |
| 202 | public static boolean isTrue(Object value) { |
| 203 | if (value == null) return false; |
| 204 | |
| 205 | value = normalizeIntIfNeeded(value); |
| 206 | |
| 207 | if (value instanceof Boolean) { |
| 208 | return (Boolean) value; |
| 209 | } else if (value instanceof Long) { |
| 210 | return ((Long) value) != 0L; |
| 211 | } else if (value instanceof Integer) { |
| 212 | return ((Integer) value) != 0; |
| 213 | } else if (value instanceof Double) { |
| 214 | return ((Double) value) != 0.0; |
| 215 | } else if (value instanceof String) { |
| 216 | return !((String) value).isEmpty(); |
| 217 | } else if (value instanceof List) { |
| 218 | return !((List<?>) value).isEmpty(); |
| 219 | } else if (value instanceof Map) { |
| 220 | // C# returned true for any IDictionary; we can mirror that or check emptiness. |
| 221 | return true; |
| 222 | } else { |
| 223 | return false; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | public static boolean isNumber(Object number) { |
| 228 | if (number == null) return false; |