@Test public void testContains() { String[] strings = new String[] {"oh", "hello", "world"}; Assert.assertFalse(StringUtil.contains(strings, "yes", true)); Assert.assertTrue(StringUtil.contains(strings, "hello", true)); Assert.assertTrue(StringUtil.contains(strings, "Hello", false)); Assert.assertTrue(StringUtil.containSubstring(strings, "llo", true)); System.out.println(String.format("[CRAFT-ATOM-UTIL] (^_^) <%s> Case -> test contains. ", CaseCounter.incr(4))); }
public static boolean contains(String[] strings, String string, boolean caseSensitive) { if (strings == null || strings.length == 0) { return false; } if (string == null || string.length() == 0) { return false; } for (int i = 0; i < strings.length; i++) { if (caseSensitive == true) { if (strings[i].equals(string)) { return true; } } else { if (strings[i].equalsIgnoreCase(string)) { return true; } } } return false; }
StringUtil { public static boolean contains(String[] strings, String string, boolean caseSensitive) { if (strings == null || strings.length == 0) { return false; } if (string == null || string.length() == 0) { return false; } for (int i = 0; i < strings.length; i++) { if (caseSensitive == true) { if (strings[i].equals(string)) { return true; } } else { if (strings[i].equalsIgnoreCase(string)) { return true; } } } return false; } }
StringUtil { public static boolean contains(String[] strings, String string, boolean caseSensitive) { if (strings == null || strings.length == 0) { return false; } if (string == null || string.length() == 0) { return false; } for (int i = 0; i < strings.length; i++) { if (caseSensitive == true) { if (strings[i].equals(string)) { return true; } } else { if (strings[i].equalsIgnoreCase(string)) { return true; } } } return false; } private  StringUtil(); }
StringUtil { public static boolean contains(String[] strings, String string, boolean caseSensitive) { if (strings == null || strings.length == 0) { return false; } if (string == null || string.length() == 0) { return false; } for (int i = 0; i < strings.length; i++) { if (caseSensitive == true) { if (strings[i].equals(string)) { return true; } } else { if (strings[i].equalsIgnoreCase(string)) { return true; } } } return false; } private  StringUtil(); static String dbc2sbcCase(String src); static String sbc2dbcCase(String src); static String toString(String[] array, String delim); static boolean contains(String[] strings, String string, boolean caseSensitive); static boolean containSubstring(String[] strings, String string, boolean caseSensitive); static int count(String src, String target); static String firstCharToLowerCase(String src); static String firstCharToUpperCase(String src); static String toCurrencyString(String src, Locale locale); static String toCurrencyString(Double src, Locale locale); static String replace(String prefix, String src, String value); static String getReplaceString(String src, String[] values); static String replace(String prefix, String src, String[] values); static String insert(String src, String target, int index); static boolean isEmpty(String str); static boolean isBlank(String str); static boolean isAnyEmpty(String... strings); static boolean isAnyBlank(String... strings); static boolean isAllEmpty(String... strings); static boolean isAllBlank(String... strings); static boolean isAllNotBlank(String... strings); static boolean isAllNotEmpty(String... strings); static boolean isDigitalString(String src); static boolean hasLength(CharSequence src); static boolean hasText(CharSequence str); static String trimAll(String src); static String trimLeading(String str); static String trimTrailing(String str); static String[] split(String str, int num); }
StringUtil { public static boolean contains(String[] strings, String string, boolean caseSensitive) { if (strings == null || strings.length == 0) { return false; } if (string == null || string.length() == 0) { return false; } for (int i = 0; i < strings.length; i++) { if (caseSensitive == true) { if (strings[i].equals(string)) { return true; } } else { if (strings[i].equalsIgnoreCase(string)) { return true; } } } return false; } private  StringUtil(); static String dbc2sbcCase(String src); static String sbc2dbcCase(String src); static String toString(String[] array, String delim); static boolean contains(String[] strings, String string, boolean caseSensitive); static boolean containSubstring(String[] strings, String string, boolean caseSensitive); static int count(String src, String target); static String firstCharToLowerCase(String src); static String firstCharToUpperCase(String src); static String toCurrencyString(String src, Locale locale); static String toCurrencyString(Double src, Locale locale); static String replace(String prefix, String src, String value); static String getReplaceString(String src, String[] values); static String replace(String prefix, String src, String[] values); static String insert(String src, String target, int index); static boolean isEmpty(String str); static boolean isBlank(String str); static boolean isAnyEmpty(String... strings); static boolean isAnyBlank(String... strings); static boolean isAllEmpty(String... strings); static boolean isAllBlank(String... strings); static boolean isAllNotBlank(String... strings); static boolean isAllNotEmpty(String... strings); static boolean isDigitalString(String src); static boolean hasLength(CharSequence src); static boolean hasText(CharSequence str); static String trimAll(String src); static String trimLeading(String str); static String trimTrailing(String str); static String[] split(String str, int num);  }