| 279 | } |
| 280 | |
| 281 | public static boolean isEqual(Object a, Object b) { |
| 282 | try { |
| 283 | if (a == null && b == null) return true; |
| 284 | if (a == null || b == null) return false; |
| 285 | |
| 286 | // If types differ and neither is numeric, they're not equal |
| 287 | if (!a.getClass().equals(b.getClass()) && !(isNumber(a) && isNumber(b))) { |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | if (IsInteger(a) && IsInteger(b)) { |
| 292 | return toLong(a).equals(toLong(b)); |
| 293 | } |
| 294 | if ((a instanceof Long) && (b instanceof Long)) { |
| 295 | return ((Long) a).longValue() == ((Long) b).longValue(); |
| 296 | } |
| 297 | if (a instanceof Double || b instanceof Double) { |
| 298 | return toDouble(a) == toDouble(b); |
| 299 | } |
| 300 | if (a instanceof Float || b instanceof Float) { |
| 301 | return toFloat(a) == toFloat(b); |
| 302 | } |
| 303 | if (a instanceof String && b instanceof String) { |
| 304 | return ((String) a).equals((String) b); |
| 305 | } |
| 306 | if (a instanceof Boolean && b instanceof Boolean) { |
| 307 | return ((Boolean) a).booleanValue() == ((Boolean) b).booleanValue(); |
| 308 | } |
| 309 | // decimal cases mapped via BigDecimal compare |
| 310 | if (isNumber(a) && isNumber(b)) { |
| 311 | return new BigDecimal(String.valueOf(a)).compareTo(new BigDecimal(String.valueOf(b))) == 0; |
| 312 | } |
| 313 | return false; |
| 314 | } catch (Exception ignored) { |
| 315 | return false; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | public static boolean isGreaterThan(Object a, Object b) { |
| 320 | if (a != null && b == null) return true; |