Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Combined "OR" Queries - Not Available #84

Open
SeloSlav opened this issue Apr 4, 2017 · 0 comments
Open

Multiple Combined "OR" Queries - Not Available #84

SeloSlav opened this issue Apr 4, 2017 · 0 comments

Comments

@SeloSlav
Copy link

SeloSlav commented Apr 4, 2017

I'm trying to build a combined ParseQuery like the one shown here: http://stackoverflow.com/questions/28892973/multiple-combined-or-queries-using-android-parse

Unfortunately, it doesn't seem the .or() method is provided in Parse4J.

I tried building my own class to include it:

import org.parse4j.ParseObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class ParseQuery<T extends ParseObject> {

    private static Logger LOGGER = LoggerFactory.getLogger(ParseQuery.class);

    /**
     * Constructs a query that is the {@code or} of the given queries.
     *
     * @param queries
     *          The list of {@code ParseQuery}s to 'or' together
     * @return A {@code ParseQuery} that is the 'or' of the passed in queries
     */
    public static <T extends ParseObject> ParseQuery<T> or(List<ParseQuery<T>> queries) {
        if (queries.isEmpty()) {
            throw new IllegalArgumentException("Can't take an or of an empty list of queries");
        }

        List<State.Builder<T>> builders = new ArrayList<>();
        for (ParseQuery<T> query : queries) {
            builders.add(query.getBuilder());
        }
        return new ParseQuery<>(State.Builder.or(builders));
    }

}

Does anybody know which class "State" happens to be? I found this code in the ParsePlatform Android SDK: https://github.com/thiagolocatelli/parse4j/blob/master/src/main/java/org/parse4j/ParseQuery.java

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant