- public static String join(CharSequence separator, Iterable<? extends CharSequence> list) {
- StringBuilder buf = new StringBuilder();
- for (CharSequence str : list) {
- if (buf.length() > 0) {
- buf.append(separator);
- }
- buf.append(str);
- }
-
- return buf.toString();
- }
-
- 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 canonicalizeNumber(String number, String localNumber) throws InvalidNumberException {
- return PhoneNumberFormatter.formatNumber(number, localNumber);
- }
-
- public static SignalServiceAddress getSignalServiceAddressFromIdentifier(final String identifier) {
- if (UuidUtil.isUuid(identifier)) {
- return new SignalServiceAddress(UuidUtil.parseOrNull(identifier), null);
- } else {
- return new SignalServiceAddress(null, identifier);
- }