Skip to content

Instantly share code, notes, and snippets.

@Ansh1234
Created April 26, 2017 12:58
Show Gist options
  • Save Ansh1234/6e57991d27900cece3ef498afa1ad180 to your computer and use it in GitHub Desktop.
Save Ansh1234/6e57991d27900cece3ef498afa1ad180 to your computer and use it in GitHub Desktop.
@NonNull
public static String formatScript(@NonNull final String function,
@Nullable final Object... params) {
final StringBuilder builder = new StringBuilder(function).append('(');
final int length = params.length;
for (int i = 0; i < params.length; ++i) {
if (params[i] instanceof String) {
builder.append("\'");
}
builder.append(params[i]);
if (params[i] instanceof String) {
builder.append("\'");
}
if (i != length - 1) {
builder.append(",");
}
}
builder.append(')');
return builder.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment