@Test public void testWrapForLikeArgumentEmptyQuotes() throws Exception { assertEquals("'%%'", SqlUtils.wrapForLikeArgument("''")); }
@NonNull public static String wrapForLikeArgument(@NonNull final String escapedString) { if (escapedString.isEmpty()) { throw new IllegalArgumentException("The input must not be empty"); } if (escapedString.length() < 2 || escapedString.charAt(0) != '\'' || escapedString.charAt(escapedString.length() - 1) != '\'') { throw new IllegalArgumentException("The input must be wrapped in single quotes"); } final StringBuilder sb = new StringBuilder(escapedString.length() + 2); sb.append(escapedString); sb.insert(1, '%'); sb.insert(sb.length() - 1, '%'); return sb.toString(); }
SqlUtils { @NonNull public static String wrapForLikeArgument(@NonNull final String escapedString) { if (escapedString.isEmpty()) { throw new IllegalArgumentException("The input must not be empty"); } if (escapedString.length() < 2 || escapedString.charAt(0) != '\'' || escapedString.charAt(escapedString.length() - 1) != '\'') { throw new IllegalArgumentException("The input must be wrapped in single quotes"); } final StringBuilder sb = new StringBuilder(escapedString.length() + 2); sb.append(escapedString); sb.insert(1, '%'); sb.insert(sb.length() - 1, '%'); return sb.toString(); } }
SqlUtils { @NonNull public static String wrapForLikeArgument(@NonNull final String escapedString) { if (escapedString.isEmpty()) { throw new IllegalArgumentException("The input must not be empty"); } if (escapedString.length() < 2 || escapedString.charAt(0) != '\'' || escapedString.charAt(escapedString.length() - 1) != '\'') { throw new IllegalArgumentException("The input must be wrapped in single quotes"); } final StringBuilder sb = new StringBuilder(escapedString.length() + 2); sb.append(escapedString); sb.insert(1, '%'); sb.insert(sb.length() - 1, '%'); return sb.toString(); } private  SqlUtils(); }
SqlUtils { @NonNull public static String wrapForLikeArgument(@NonNull final String escapedString) { if (escapedString.isEmpty()) { throw new IllegalArgumentException("The input must not be empty"); } if (escapedString.length() < 2 || escapedString.charAt(0) != '\'' || escapedString.charAt(escapedString.length() - 1) != '\'') { throw new IllegalArgumentException("The input must be wrapped in single quotes"); } final StringBuilder sb = new StringBuilder(escapedString.length() + 2); sb.append(escapedString); sb.insert(1, '%'); sb.insert(sb.length() - 1, '%'); return sb.toString(); } private  SqlUtils(); @NonNull static String escapeAndWrapForLikeArgument(@Nullable final String string); @NonNull static String wrapForLikeArgument(@NonNull final String escapedString); }
SqlUtils { @NonNull public static String wrapForLikeArgument(@NonNull final String escapedString) { if (escapedString.isEmpty()) { throw new IllegalArgumentException("The input must not be empty"); } if (escapedString.length() < 2 || escapedString.charAt(0) != '\'' || escapedString.charAt(escapedString.length() - 1) != '\'') { throw new IllegalArgumentException("The input must be wrapped in single quotes"); } final StringBuilder sb = new StringBuilder(escapedString.length() + 2); sb.append(escapedString); sb.insert(1, '%'); sb.insert(sb.length() - 1, '%'); return sb.toString(); } private  SqlUtils(); @NonNull static String escapeAndWrapForLikeArgument(@Nullable final String string); @NonNull static String wrapForLikeArgument(@NonNull final String escapedString);  }