MCPcopy
hub / github.com/ccxt/ccxt / isTrue

Method isTrue

java/lib/src/main/java/io/github/ccxt/Helpers.java:202–225  ·  view source on GitHub ↗
(Object value)

Source from the content-addressed store, hash-verified

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;

Callers 15

crc32Method · 0.95
safeBoolNMethod · 0.95
safeBool2Method · 0.95
safeBoolMethod · 0.95
safeDictNMethod · 0.95
safeDictMethod · 0.95
safeDict2Method · 0.95
safeListNMethod · 0.95
isDictionaryMethod · 0.95
safeList2Method · 0.95
safeListMethod · 0.95
findTimeframeMethod · 0.95

Calls 2

normalizeIntIfNeededMethod · 0.95
isEmptyMethod · 0.80

Tested by 15

isTrueMethod · 0.76
testSignInMethod · 0.76
testTickerMethod · 0.76
testFetchOHLCVMethod · 0.76
testCurrencyMethod · 0.76
testFetchLedgerEntryMethod · 0.76
testTradeMethod · 0.76
testMarketMethod · 0.76
testFetchLiquidationsMethod · 0.76
testOHLCVMethod · 0.76
testLiquidationMethod · 0.76