Skip to content

Multiple Combined "OR" Queries - Not Available #84

@SeloSlav

Description

@SeloSlav

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions