Collection<String> () { TreePath selection = getSelectionPath(); Object value = selection == null ? null : selection.getLastPathComponent(); if (value instanceof MessageNode messageNode) { return Arrays.asList(messageNode.getText()); } return value == null ? null : Collections.singleton(value.toString()); }