aboutsummaryrefslogtreecommitdiff
path: root/server-core/src/main/java/com/juick/util/MessageUtils.java
blob: 1e8165c36527c83cf8a97a6595a77602ed900596 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.juick.util;

/**
 * Created by aalexeev on 11/13/16.
 */
public class MessageUtils {
    private MessageUtils() {
        throw new IllegalStateException();
    }

    public static String formatQuote(final String quote) {
        String result = quote;

        if (quote != null) {
            if (quote.length() > 50) {
                result = ">" + quote.substring(0, 47).replace('\n', ' ') + "...\n";
            } else if (!quote.isEmpty()) {
                result = ">" + quote.replace('\n', ' ') + "\n";
            }
        }

        return result;
    }
}