StringUtil { public static boolean commonSuffixOfLength(String s, String p, int len) { return s != null && p != null && len >= 0 && s.regionMatches(s.length() - len, p, p.length() - len, len); } private  StringUtil(); static String[] split(String value, char delim); static String[] split(String value, char delim, int maxParts); static String substringAfter(String value, char delim); static boolean commonSuffixOfLength(String s, String p, int len); static String byteToHexStringPadded(int value); static T byteToHexStringPadded(T buf, int value); static String toHexStringPadded(byte[] src); static String toHexStringPadded(byte[] src, int offset, int length); static T toHexStringPadded(T dst, byte[] src); static T toHexStringPadded(T dst, byte[] src, int offset, int length); static String byteToHexString(int value); static T byteToHexString(T buf, int value); static String toHexString(byte[] src); static String toHexString(byte[] src, int offset, int length); static T toHexString(T dst, byte[] src); static T toHexString(T dst, byte[] src, int offset, int length); static String simpleClassName(Object o); static String simpleClassName(Class<?> clazz); static CharSequence escapeCsv(CharSequence value); static int length(String s); static boolean isNullOrEmpty(String s); static boolean isSurrogate(char c); static final String EMPTY_STRING; static final String NEWLINE; static final char DOUBLE_QUOTE; static final char COMMA; static final char LINE_FEED; static final char CARRIAGE_RETURN; static final char TAB; }
@Test public void commonSuffixOfLengthTest() { checkNotCommonSuffix("abc", "abc", -1); checkNotCommonSuffix("abc", null, 0); checkNotCommonSuffix(null, null, 0); checkCommonSuffix("abc", "xx", 0); checkCommonSuffix("abc", "abc", 0); checkCommonSuffix("abc", "abc", 1); checkCommonSuffix("abc", "abc", 2); checkCommonSuffix("abc", "abc", 3); checkNotCommonSuffix("abc", "abc", 4); checkCommonSuffix("abcd", "cd", 1); checkCommonSuffix("abcd", "cd", 2); checkNotCommonSuffix("abcd", "cd", 3); checkCommonSuffix("abcd", "axcd", 1); checkCommonSuffix("abcd", "axcd", 2); checkNotCommonSuffix("abcd", "axcd", 3); checkNotCommonSuffix("abcx", "abcy", 1); }