@Test public void testEndWithIgnoreCase() { Object[] testData = new Object[] { null, null, true, "", "", true, "", "foo", false, "foo", "foo", true, "foo.bar", "bar", true, "foo.bar", "barX", false, "foo.barX", "bar", false, "foo", "bar", false, "foo.BAR", "bar", true, "foo.bar", "BaR", true }; for (int i = 0; i < testData.length; i += 3) { boolean actualResult = StringUtil.endsWithIgnoreCase( (String) testData[i], (String) testData[i + 1]); boolean expectedResult = (Boolean) testData[i + 2]; assertEquals( (i / 3) + " : " + testData[i] + ", " + testData[i + 1], expectedResult, actualResult); } }
public static boolean endsWithIgnoreCase(String source, String suffix) { if (isEmpty(suffix)) { return true; } if (isEmpty(source)) { return false; } if (suffix.length() > source.length()) { return false; } return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLowerCase()); }
StringUtil { public static boolean endsWithIgnoreCase(String source, String suffix) { if (isEmpty(suffix)) { return true; } if (isEmpty(source)) { return false; } if (suffix.length() > source.length()) { return false; } return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLowerCase()); } }
StringUtil { public static boolean endsWithIgnoreCase(String source, String suffix) { if (isEmpty(suffix)) { return true; } if (isEmpty(source)) { return false; } if (suffix.length() > source.length()) { return false; } return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLowerCase()); }  }
StringUtil { public static boolean endsWithIgnoreCase(String source, String suffix) { if (isEmpty(suffix)) { return true; } if (isEmpty(source)) { return false; } if (suffix.length() > source.length()) { return false; } return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLowerCase()); }  static String collapsePathDots(String path); static boolean isNotBlank(String text); static boolean isBlank(String text); static boolean isEmpty(String text); static boolean endsWithIgnoreCase(String source, String suffix); static String defaultIfNull(String text); static String defaultIfNull(String text, String defaultValue); static boolean equals(String text1, String text2); static String toString(Object... keyValues); static int hashCode(String... values); static String substringBefore(String text, char separator); static String substringBeforeLast(String text, char separator); static String substringAfterLast(String text, char separator); static String substringAfter(String text, char c); }
StringUtil { public static boolean endsWithIgnoreCase(String source, String suffix) { if (isEmpty(suffix)) { return true; } if (isEmpty(source)) { return false; } if (suffix.length() > source.length()) { return false; } return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLowerCase()); }  static String collapsePathDots(String path); static boolean isNotBlank(String text); static boolean isBlank(String text); static boolean isEmpty(String text); static boolean endsWithIgnoreCase(String source, String suffix); static String defaultIfNull(String text); static String defaultIfNull(String text, String defaultValue); static boolean equals(String text1, String text2); static String toString(Object... keyValues); static int hashCode(String... values); static String substringBefore(String text, char separator); static String substringBeforeLast(String text, char separator); static String substringAfterLast(String text, char separator); static String substringAfter(String text, char c);  }