private String formatStateLabel(State state) {
        StringBuilder formatted = new StringBuilder();
        if(direction.equals("TD") || direction.equals("DT")) {
            formatted.append('{');
        }

        formatted.append(ensureTextIsValid(state.getName()));
        String description = state.getDescription();
        if (StringUtils.isNotBlank(description)) {
            formatted.append("\\n|");
            formatted.append(ensureTextIsValid(description));
        }

        if(direction.equals("TD") || direction.equals("DT")) {
            formatted.append('}');
        }
        return formatted.toString();
    }