StringUtil { public static boolean substringMatch(CharSequence str, int index, CharSequence substring) { if (index + substring.length() > str.length()) { return false; } for (int i = 0; i < substring.length(); i++) { if (str.charAt(index + i) != substring.charAt(i)) { return false; } } return true; }  static boolean isEmpty(String str); static boolean isNotEmpty(String str); static void setIfPresent(String value, Consumer<String> setter); static String join(final char delimiter, final String... strings); static boolean substringMatch(CharSequence str, int index, CharSequence substring); static String cut(String str, int threshold); static String trim(final String str, final char ch);  }
@Test public void testSubstringMatchReturningTrue() { StringBuffer stringBuffer = new StringBuffer("ZP~>xz1;"); Assert.assertTrue(StringUtil.substringMatch(stringBuffer, 0, stringBuffer)); }
@Test public void testSubstringMatchWithPositive() { Assert.assertFalse(StringUtil.substringMatch("", 4770, "")); }