- public static JsonNode getNotNullNode(JsonNode parent, String name) throws InvalidObjectException {
- JsonNode node = parent.get(name);
- if (node == null) {
- throw new InvalidObjectException(String.format("Incorrect file format: expected parameter %s not found ", name));
- }
-
- return node;
- }
-
- public static byte[] decodeGroupId(String groupId) throws GroupIdFormatException {
- try {
- return Base64.decode(groupId);
- } catch (IOException e) {
- throw new GroupIdFormatException(groupId, e);
+ public static String formatSafetyNumber(String digits) {
+ final var partCount = 12;
+ var partSize = digits.length() / partCount;
+ var f = new StringBuilder(digits.length() + partCount);
+ for (var i = 0; i < partCount; i++) {
+ f.append(digits, i * partSize, (i * partSize) + partSize).append(" ");