// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/Condition.java
// public enum Type {
//     NORMAL("NORMAL"), NO_ARGS("NO_ARGS"), BEGIN_GROUP("BEGIN_GROUP"), END_GROUP("END_GROUP"), OR("OR"), NOT("NOT");
// 
//     private final String name;
// 
//     Type(String name) {
//         this.name = name;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public static Type getForName(String name) {
//         switch (name) {
//             case "NORMAL":
//                 return NORMAL;
//             case "NO_ARGS":
//                 return NO_ARGS;
//             case "BEGIN_GROUP":
//                 return BEGIN_GROUP;
//             case "END_GROUP":
//                 return END_GROUP;
//             case "OR":
//                 return OR;
//             case "NOT":
//                 return NOT;
//             default:
//                 throw new IllegalArgumentException("Invalid Condition type name.");
//         }
//     }
// }
// 
// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/ReadableStringUtils.java
// public static boolean isAnyOf(Condition condition, Condition.Type... types) {
//     if (condition == null) return false;
//     for (Condition.Type type : types) if (condition.getType() == type) return true;
//     return false;
// }
// 
// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/ReadableStringUtils.java
// public static boolean isNoneOf(Condition condition, Condition.Type... types) {
//     if (condition == null) return false;
//     for (Condition.Type type : types) if (condition.getType() == type) return false;
//     return true;
// }


import android.os.Parcel;
import android.os.Parcelable;
import com.squareup.phrase.ListPhrase;
import io.realm.Realm;
import io.realm.RealmModel;
import io.realm.RealmResults;
import io.realm.Sort;
import java.util.ArrayList;
import java.util.regex.Pattern;
import static com.bkromhout.ruqus.Condition.Type.*;
import static com.bkromhout.ruqus.ReadableStringUtils.isAnyOf;
import static com.bkromhout.ruqus.ReadableStringUtils.isNoneOf;
     * @return Human-readable query string.
     */
    @Override
    public String toString() {
        if (!isQueryValid()) return null;
        // Build up visible string. Start by stating the visible name of the type our results will be.
        StringBuilder builder = new StringBuilder()
                .append("Find all ")
                .append(Ruqus.getClassData().visibleNameOf(queryClass));

        // Next, loop through any conditions, appending their human-readable strings and applicable separators.
        if (!conditions.isEmpty()) {
            builder.append(" where ");

            for (int i = 0; i < conditions.size(); i++) {
                Condition previous = i - 1 >= 0 ? conditions.get(i - 1) : null;
                Condition current = conditions.get(i);
                Condition next = i + 1 < conditions.size() ? conditions.get(i + 1) : null;

                // Append human-readable condition string.
                String conditionPart = current.makeReadableString(previous, next);
                builder.append(conditionPart);

                // If we don't have any more conditions after this one, just append a period and continue.
                if (next == null) {
                    builder.append(".");
                    continue;
                }

                // Append a space if applicable.
// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/Condition.java
// public enum Type {
//     NORMAL("NORMAL"), NO_ARGS("NO_ARGS"), BEGIN_GROUP("BEGIN_GROUP"), END_GROUP("END_GROUP"), OR("OR"), NOT("NOT");
// 
//     private final String name;
// 
//     Type(String name) {
//         this.name = name;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public static Type getForName(String name) {
//         switch (name) {
//             case "NORMAL":
//                 return NORMAL;
//             case "NO_ARGS":
//                 return NO_ARGS;
//             case "BEGIN_GROUP":
//                 return BEGIN_GROUP;
//             case "END_GROUP":
//                 return END_GROUP;
//             case "OR":
//                 return OR;
//             case "NOT":
//                 return NOT;
//             default:
//                 throw new IllegalArgumentException("Invalid Condition type name.");
//         }
//     }
// }
// 
// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/ReadableStringUtils.java
// public static boolean isAnyOf(Condition condition, Condition.Type... types) {
//     if (condition == null) return false;
//     for (Condition.Type type : types) if (condition.getType() == type) return true;
//     return false;
// }
// 
// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/ReadableStringUtils.java
// public static boolean isNoneOf(Condition condition, Condition.Type... types) {
//     if (condition == null) return false;
//     for (Condition.Type type : types) if (condition.getType() == type) return false;
//     return true;
// }


// Path: ruqus-core/src/main/java/com/bkromhout/ruqus/RealmUserQuery.java
import android.os.Parcel;
import android.os.Parcelable;
import com.squareup.phrase.ListPhrase;
import io.realm.Realm;
import io.realm.RealmModel;
import io.realm.RealmResults;
import io.realm.Sort;
import java.util.ArrayList;
import java.util.regex.Pattern;
import static com.bkromhout.ruqus.Condition.Type.*;
import static com.bkromhout.ruqus.ReadableStringUtils.isAnyOf;
import static com.bkromhout.ruqus.ReadableStringUtils.isNoneOf;

     * @return Human-readable query string.
     */
    @Override
    public String toString() {
        if (!isQueryValid()) return null;
        // Build up visible string. Start by stating the visible name of the type our results will be.
        StringBuilder builder = new StringBuilder()
                .append("Find all ")
                .append(Ruqus.getClassData().visibleNameOf(queryClass));

        // Next, loop through any conditions, appending their human-readable strings and applicable separators.
        if (!conditions.isEmpty()) {
            builder.append(" where ");

            for (int i = 0; i < conditions.size(); i++) {
                Condition previous = i - 1 >= 0 ? conditions.get(i - 1) : null;
                Condition current = conditions.get(i);
                Condition next = i + 1 < conditions.size() ? conditions.get(i + 1) : null;

                // Append human-readable condition string.
                String conditionPart = current.makeReadableString(previous, next);
                builder.append(conditionPart);

                // If we don't have any more conditions after this one, just append a period and continue.
                if (next == null) {
                    builder.append(".");
                    continue;
                }

                // Append a space if applicable.
                if (isNoneOf(current, BEGIN_GROUP, NOT) && isNoneOf(next, END_GROUP))