MCPcopy Index your code
hub / github.com/ccxt/ccxt / indexBy

Method indexBy

java/lib/src/main/java/io/github/ccxt/base/Generic.java:310–337  ·  view source on GitHub ↗
(Object a, Object key2)

Source from the content-addressed store, hash-verified

308 }
309
310 public static Map<String, Object> indexBy(Object a, Object key2) {
311 Map<String, Object> out = new LinkedHashMap<>();
312 List<Object> targetX;
313
314 if (a instanceof List<?>) {
315 targetX = (List<Object>) a;
316 } else {
317 targetX = new ArrayList<>(((Map<String, Object>) a).values());
318 }
319
320 for (Object elem : targetX) {
321 if (elem instanceof Map<?, ?>) {
322 Map<String, Object> m = (Map<String, Object>) elem;
323 Object val = m.get((String) key2);
324 if (val == null) continue;
325 out.put(val.toString(), m);
326 } else if (elem instanceof List<?>) {
327 int index = Integer.parseInt(String.valueOf(key2));
328 List<?> l = (List<?>) elem;
329 if (l.isEmpty()) continue;
330 if (index < 0 || index >= l.size()) continue;
331 Object val = l.get(index);
332 if (val == null) continue;
333 out.put(val.toString(), elem);
334 }
335 }
336 return out;
337 }
338
339 // ---------- groupBy ----------
340

Callers 15

indexBySafeMethod · 0.95
fetchOrderMethod · 0.45
parseMarketMethod · 0.45
loadMarketsMethod · 0.45
fetchOrderStatusMethod · 0.45
parseDepositAddressMethod · 0.45
fetchPositionModeMethod · 0.45
fetchCurrenciesMethod · 0.45
fetchCurrenciesMethod · 0.45
fetchMarketsFromAPIMethod · 0.45
fetchDepositAddressMethod · 0.45

Calls 5

parseIntMethod · 0.80
isEmptyMethod · 0.80
valuesMethod · 0.45
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected