com.squeakysand.commons.search.SearchCriteria Maven / Gradle / Ivy
Show all versions of squeakysand-commons Show documentation
/*
* Copyright 2010-2012 Craig S. Dickson (http://craigsdickson.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squeakysand.commons.search;
import java.io.Serializable;
/**
* Base class for objects representing multi-criteria search specifications.
*
* In the context of search criteria, the {@link java.lang.Object#equals(Object)} method should be
* overriden to return true if the two sets of criteria will match the same set of
* entities if applied to the same search space and false otherwise.
*/
public interface SearchCriteria extends Serializable {
/**
* Indicates if the current criteria specified will result in a full wildcard search for all
* entities.
*
* This method acknowledges the fact that some search spaces can be massive (millions of
* lines in a single table in a database for example). Searching for elements in these spaces
* can be extremely resource intensive and result in degraded quality of service for clients.
*
*
* Alternatively, in certain scenarios, knowing that the criteria will match all elements in
* a search space may allow for an alternative, simpler, and faster search algorithm to be used.
*
*
* @return true if the current combination of criteria will match all elements in
* a search space and false otherwise.
*/
boolean matchesAll();
/**
* Indicates if the current criteria specified represents a valid combination of criteria to
* search by.
*
* This method acknowledges the fact that when multiple criteria can be used in combination
* to define a search, only a subset of the combinations of these criteria may result in a valid
* search being performed. For example, in the scenario where seaching by date ranges is
* allowed, then this method should probably return false if the end date is earlier than the
* start date.
*
* @return true if the current combination of criteria is valid and
* false otherwise.
*/
boolean isValid();
}