MCPcopy
hub / github.com/ccxt/ccxt / isEqual

Method isEqual

java/lib/src/main/java/io/github/ccxt/Helpers.java:281–317  ·  view source on GitHub ↗
(Object a, Object b)

Source from the content-addressed store, hash-verified

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;

Callers 15

safeDictNMethod · 0.95
safeDictMethod · 0.95
safeListNMethod · 0.95
isDictionaryMethod · 0.95
safeList2Method · 0.95
safeListMethod · 0.95
findTimeframeMethod · 0.95
checkProxyUrlSettingsMethod · 0.95
checkAddressMethod · 0.95
filterByLimitMethod · 0.95
filterBySinceLimitMethod · 0.95

Calls 6

isNumberMethod · 0.95
IsIntegerMethod · 0.95
toLongMethod · 0.95
toDoubleMethod · 0.95
toFloatMethod · 0.95
equalsMethod · 0.45

Tested by 15

isEqualMethod · 0.76
deepEqualMethod · 0.76
testFetchOrderBooksMethod · 0.76
testLoadMarketsMethod · 0.76
testTickerMethod · 0.76
testCurrencyMethod · 0.76
testTradeMethod · 0.76
testMarketMethod · 0.76
testOHLCVMethod · 0.76
testLiquidationMethod · 0.76
testBalanceMethod · 0.76
testProxyUrlMethod · 0.76