Android Open Source - Android-Lib-Database Two Sided Predicate






From Project

Back to project page Android-Lib-Database.

License

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.

Java Source Code

package android.lib.database.predicate;
// w  w  w. j  av a2  s . c o m
import java.util.ArrayList;
import java.util.List;

final class TwoSidedPredicate extends Predicate {
    private TwoSidedPredicate(final String predicate, final List<Object> parameters) {
        super(predicate, parameters);
    }

    public static TwoSidedPredicate newInstance(final String template, final Object left, final Object right, final boolean leftIsValue, final boolean rightIsValue) {
        final List<Object> parameters = new ArrayList<Object>();
        final String       predicate;

        if (leftIsValue) {
            parameters.add(left);
        }

        if (rightIsValue) {
            parameters.add(right);
        }

        if (leftIsValue) {
            if (rightIsValue) {
                predicate = String.format(template, Predicate.PARAMETER, Predicate.PARAMETER);
            } else {
                predicate = String.format(template, Predicate.PARAMETER, right.toString());
            }
        } else {
            if (rightIsValue) {
                predicate = String.format(template, left, Predicate.PARAMETER);
            } else {
                predicate = String.format(template, left, right);
            }
        }

        return new TwoSidedPredicate(predicate, parameters);
    }
}




Java Source Code List

android.lib.database.Column.java
android.lib.database.CompositeIndex.java
android.lib.database.DatabaseOpenHelper.java
android.lib.database.Database.java
android.lib.database.DateConverter.java
android.lib.database.Index.java
android.lib.database.JSONRowMapper.java
android.lib.database.RowMapper.java
android.lib.database.Table.java
android.lib.database.TypeConverter.java
android.lib.database.UniqueCompositeIndex.java
android.lib.database.UnsupportedTypeException.java
android.lib.database.UseConverter.java
android.lib.database.predicate.ManySidedPredicate.java
android.lib.database.predicate.Predicate.java
android.lib.database.predicate.ThreeSidedPredicate.java
android.lib.database.predicate.TwoSidedPredicate.java
android.lib.database.query.Delete.java
android.lib.database.query.Insert.java
android.lib.database.query.QueryBuilder.java
android.lib.database.query.Query.java
android.lib.database.query.Select.java
android.lib.database.query.Update.java