void (@NotNull String sgrSequenceBody) { /* The ITU's T.416 Information technology - Open Document Architecture (ODA) and interchange format: https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-T.416-199303-I!!PDF-E&type=items uses ':' as separator characters instead * */ String separator = StringUtil.containsChar(sgrSequenceBody, ':') ? ":" : ";"; List<String> sgrSequenceParts = StringUtil.split(sgrSequenceBody, separator, true, false); Iterator<Integer> sgrCodesIterator = ContainerUtil.map(sgrSequenceParts, it -> { try { return it.isEmpty() ? 0 : Integer.parseInt(it); } catch (NumberFormatException e) { LOG.warn("Could not parse integer: " + it + " in " + sgrSequenceBody); return null; } }).iterator(); while (sgrCodesIterator.hasNext()) { Integer command = sgrCodesIterator.next(); if (command == null) { break; } processSgr(command, sgrCodesIterator); } }