All Downloads are FREE. Search and download functionalities are using the official Maven repository.

run.halo.app.extension.index.query.LogicalQuery Maven / Gradle / Ivy

The newest version!
package run.halo.app.extension.index.query;

import java.util.Collection;
import java.util.Objects;
import lombok.Getter;

@Getter
public abstract class LogicalQuery implements Query {
    protected final Collection childQueries;
    protected final int size;

    /**
     * Creates a new logical query with the given child queries.
     *
     * @param childQueries with the given child queries.
     */
    public LogicalQuery(Collection childQueries) {
        Objects.requireNonNull(childQueries,
            "The child queries supplied to a logical query cannot be null");
        for (Query query : childQueries) {
            if (!isValid(query)) {
                throw new IllegalStateException("Unexpected type of query: " + (query == null ? null
                    : query + ", " + query.getClass()));
            }
        }
        this.size = childQueries.size();
        this.childQueries = childQueries;
    }

    boolean isValid(Query query) {
        return query instanceof LogicalQuery || query instanceof SimpleQuery;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy