(Map<String, Object> api, List<String> paths)
| 383 | } |
| 384 | |
| 385 | private void transformApiNew(Map<String, Object> api, List<String> paths) { |
| 386 | if (api == null) { |
| 387 | return; |
| 388 | } |
| 389 | |
| 390 | if (paths == null) { |
| 391 | paths = new ArrayList<>(); |
| 392 | } |
| 393 | |
| 394 | List<String> keyList = new ArrayList<>(api.keySet()); |
| 395 | |
| 396 | for (String key : keyList) { |
| 397 | Object value = api.get(key); |
| 398 | |
| 399 | if (isHttpMethod(key)) { |
| 400 | Map<String, Object> dictValue = null; |
| 401 | List<String> endpoints = null; |
| 402 | |
| 403 | if (value instanceof Map) { |
| 404 | dictValue = (Map<String, Object>) value; |
| 405 | endpoints = new ArrayList<>(dictValue.keySet()); |
| 406 | } else if (value instanceof List) { |
| 407 | // when endpoints are a list of strings |
| 408 | endpoints = new ArrayList<>(); |
| 409 | List<?> listValue = (List<?>) value; |
| 410 | for (Object item : listValue) { |
| 411 | endpoints.add(String.valueOf(item)); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | if (endpoints == null) { |
| 416 | continue; |
| 417 | } |
| 418 | |
| 419 | for (String endpoint : endpoints) { |
| 420 | double cost = 1.0; |
| 421 | |
| 422 | if (dictValue != null) { |
| 423 | Object config = dictValue.get(endpoint); |
| 424 | |
| 425 | if (config instanceof Map) { |
| 426 | Map<String, Object> dictConfig = (Map<String, Object>) config; |
| 427 | Object rl = dictConfig.get("cost"); |
| 428 | if (rl != null) { |
| 429 | cost = toDoubleSafe(rl, 1.0); |
| 430 | } |
| 431 | } else { |
| 432 | try { |
| 433 | if (config != null) { |
| 434 | cost = toDoubleSafe(config, 1.0); |
| 435 | } |
| 436 | } catch (Exception ignored) { |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | // split endpoint by non-alphanumeric chars |
| 442 | String[] result = endpoint.split("[^a-zA-Z0-9]+"); |
no test coverage detected