001/*
002 * Copyright 2014 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.service.common;
017
018import org.gbif.api.model.common.search.FacetedSearchRequest;
019import org.gbif.api.model.common.search.SearchParameter;
020import org.gbif.api.model.common.search.SearchRequest;
021import org.gbif.api.model.common.search.SearchResponse;
022
023/**
024 * Parameterized generic search interface that supports pagination.
025 * The generic {@link SearchResponse} and {@link SearchRequest} are used to provide the basic search parameters
026 * in a request and allow facets for results.
027 * This marker interface should be extended by other interfaces that support full text, faceted and paginated search.
028 *
029 * @param <T> the type of returned results
030 * @param <P> the supported search parameter enumeration
031 * @param <R> the supported search request type. For faceted searches this needs to extend {@link FacetedSearchRequest}
032 */
033public interface SearchService<T, P extends Enum<?> & SearchParameter, R extends SearchRequest<P>> {
034
035  /**
036   * Issues a SearchRequest and retrieves a response resulting of the search operation.
037   * The actual result information will contain a list elements of type T.
038   *
039   * @param searchRequest the searchRequest that contains the search parameters
040   *
041   * @return the SearchResponse resulting of the search operation
042   */
043  SearchResponse<T, P> search(R searchRequest);
044
045}