Back to project page Android-Lib-Database.
The source code is released under:
Apache License
If you think the Android project Android-Lib-Database listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package android.lib.database.predicate; /*from w w w.ja v a2s . c o m*/ import java.util.ArrayList; import java.util.Arrays; import java.util.List; final class ManySidedPredicate extends Predicate { private static final String COMMA = ", "; //$NON-NLS-1$ private ManySidedPredicate(final String predicate, final List<Object> parameters) { super(predicate, parameters); } public static ManySidedPredicate newInstance(final String template, final Object identifier, final boolean isValue, final Object... values) { final List<Object> parameters = new ArrayList<Object>(); final StringBuilder builder = new StringBuilder(); final String predicate; for (int i = values.length; --i >= 0;) { if (builder.length() > 0) { builder.append(ManySidedPredicate.COMMA); } builder.append(Predicate.PARAMETER); } if (isValue) { predicate = String.format(template, Predicate.PARAMETER, builder.toString()); parameters.add(identifier); } else { predicate = String.format(template, identifier.toString(), builder.toString()); } parameters.addAll(Arrays.asList(values)); return new ManySidedPredicate(predicate, parameters); } }