(String primaryType, Map<String, Object> data, Map<String, List<Map<String, String>>> types)
| 2539 | } |
| 2540 | |
| 2541 | private static byte[] encodeData(String primaryType, Map<String, Object> data, Map<String, List<Map<String, String>>> types) { |
| 2542 | List<byte[]> chunks = new ArrayList<>(); |
| 2543 | for (Map<String, String> field : types.get(primaryType)) { |
| 2544 | String fieldName = field.get("name"); |
| 2545 | String fieldType = field.get("type"); |
| 2546 | chunks.add(encodeValue(fieldType, data.get(fieldName), types)); |
| 2547 | } |
| 2548 | int total = 0; |
| 2549 | for (byte[] c : chunks) total += c.length; |
| 2550 | byte[] out = new byte[total]; |
| 2551 | int pos = 0; |
| 2552 | for (byte[] c : chunks) { |
| 2553 | System.arraycopy(c, 0, out, pos, c.length); |
| 2554 | pos += c.length; |
| 2555 | } |
| 2556 | return out; |
| 2557 | } |
| 2558 | |
| 2559 | @SuppressWarnings("unchecked") |
| 2560 | private static byte[] encodeValue(String type, Object value, Map<String, List<Map<String, String>>> types) { |
no test coverage detected