@Test void emptyMessage() { assertEquals(Arrays.asList(""), ExtendedMessageFormatter.parseMessage("", new Object[]{})); }
public static List<String> parseMessage(final String messagePattern, Object[] arguments) { if (messagePattern == null) { return null; } if (arguments == null || arguments.length == 0) { return Arrays.asList(messagePattern); } List<String> messageList = new ArrayList<>(arguments.length + 1); MessageParser parser = new MessageParser(messagePattern, false); StringBuilder lastElement = new StringBuilder(); for (MessageElement element = parser.next(), previous = null; element != null; previous = element, element = parser.next()) { if (arguments.length < messageList.size()) { lastElement.append(element.getString()); } else { if (element instanceof MessageString) { messageList.add(element.getString()); } else if (!(previous instanceof MessageString)) { messageList.add(""); } } } if (lastElement.length() > 0 || parser.getCurrentMessageElement() instanceof MessageIndex) { messageList.add(lastElement.toString()); } return messageList; }
ExtendedMessageFormatter { public static List<String> parseMessage(final String messagePattern, Object[] arguments) { if (messagePattern == null) { return null; } if (arguments == null || arguments.length == 0) { return Arrays.asList(messagePattern); } List<String> messageList = new ArrayList<>(arguments.length + 1); MessageParser parser = new MessageParser(messagePattern, false); StringBuilder lastElement = new StringBuilder(); for (MessageElement element = parser.next(), previous = null; element != null; previous = element, element = parser.next()) { if (arguments.length < messageList.size()) { lastElement.append(element.getString()); } else { if (element instanceof MessageString) { messageList.add(element.getString()); } else if (!(previous instanceof MessageString)) { messageList.add(""); } } } if (lastElement.length() > 0 || parser.getCurrentMessageElement() instanceof MessageIndex) { messageList.add(lastElement.toString()); } return messageList; } }
ExtendedMessageFormatter { public static List<String> parseMessage(final String messagePattern, Object[] arguments) { if (messagePattern == null) { return null; } if (arguments == null || arguments.length == 0) { return Arrays.asList(messagePattern); } List<String> messageList = new ArrayList<>(arguments.length + 1); MessageParser parser = new MessageParser(messagePattern, false); StringBuilder lastElement = new StringBuilder(); for (MessageElement element = parser.next(), previous = null; element != null; previous = element, element = parser.next()) { if (arguments.length < messageList.size()) { lastElement.append(element.getString()); } else { if (element instanceof MessageString) { messageList.add(element.getString()); } else if (!(previous instanceof MessageString)) { messageList.add(""); } } } if (lastElement.length() > 0 || parser.getCurrentMessageElement() instanceof MessageIndex) { messageList.add(lastElement.toString()); } return messageList; } private  ExtendedMessageFormatter(); }
ExtendedMessageFormatter { public static List<String> parseMessage(final String messagePattern, Object[] arguments) { if (messagePattern == null) { return null; } if (arguments == null || arguments.length == 0) { return Arrays.asList(messagePattern); } List<String> messageList = new ArrayList<>(arguments.length + 1); MessageParser parser = new MessageParser(messagePattern, false); StringBuilder lastElement = new StringBuilder(); for (MessageElement element = parser.next(), previous = null; element != null; previous = element, element = parser.next()) { if (arguments.length < messageList.size()) { lastElement.append(element.getString()); } else { if (element instanceof MessageString) { messageList.add(element.getString()); } else if (!(previous instanceof MessageString)) { messageList.add(""); } } } if (lastElement.length() > 0 || parser.getCurrentMessageElement() instanceof MessageIndex) { messageList.add(lastElement.toString()); } return messageList; } private  ExtendedMessageFormatter(); static List<String> parseMessage(final String messagePattern, Object[] arguments); }
ExtendedMessageFormatter { public static List<String> parseMessage(final String messagePattern, Object[] arguments) { if (messagePattern == null) { return null; } if (arguments == null || arguments.length == 0) { return Arrays.asList(messagePattern); } List<String> messageList = new ArrayList<>(arguments.length + 1); MessageParser parser = new MessageParser(messagePattern, false); StringBuilder lastElement = new StringBuilder(); for (MessageElement element = parser.next(), previous = null; element != null; previous = element, element = parser.next()) { if (arguments.length < messageList.size()) { lastElement.append(element.getString()); } else { if (element instanceof MessageString) { messageList.add(element.getString()); } else if (!(previous instanceof MessageString)) { messageList.add(""); } } } if (lastElement.length() > 0 || parser.getCurrentMessageElement() instanceof MessageIndex) { messageList.add(lastElement.toString()); } return messageList; } private  ExtendedMessageFormatter(); static List<String> parseMessage(final String messagePattern, Object[] arguments);  }