2 表情包工具类
import com.dianping.cat.Cat;import com.google.common.collect.Sets;import com.vdurmont.emoji.EmojiParser;import org.apache.commons.lang3.StringUtils;import java.util.Set;@Slf4jpublic class EmojiTool extends EmojiParser { public static Set
3 emoji包情包的模糊处理工具类
import com.util.emoji.EmojiTool;import org.apache.commons.collections4.CollectionUtils;import org.apache.commons.lang3.StringUtils;import java.util.*;public class StringTool { //用户名称长度少于等于这个数字则不模糊 private int USERNAME_NOT_BLUR_NUM = 3; private StringTool() { } private static String around (String str, int strLen, int index, int end, int removeIndex) { String leftStr = StringUtils.left(str,index); String rightStr = StringUtils.right(str,end); String leftPadStr = StringUtils.leftPad(rightStr,strLen,"*"); String removeStr = leftPadStr.length() <= removeIndex ? leftPadStr : leftPadStr.substring(strLen-removeIndex); String resultStr = leftStr.concat(removeStr); return resultStr; } public static String around (String str) { if (StringUtils.isBlank(str)) { return ""; } int strLen = StringUtils.length(str); if (strLen <= USERNAME_NOT_BLUR_NUM) { return str; } //字符串头节点不模糊的字符数 int index = 1; //字符串尾节点不模糊的字符数 int end = 1; //字符串尾节点最终保留的字符数(两个*和一个普通字符) int removeIndex = 3; Set