main.java.com.cloudant.client.api.views.SettableViewParameters Maven / Gradle / Ivy
Show all versions of cloudant-client Show documentation
/*
* Copyright (c) 2015 IBM Corp. All rights reserved.
*
* 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.cloudant.client.api.views;
/**
* Describes the parameters that can be set when building view requests.
*
*
*
* Cloudant API reference
*
*
*
* @since 2.0.0
*/
public interface SettableViewParameters {
/**
* Constant for the value "ok" for use with
* {@link com.cloudant.client.api.views.SettableViewParameters.Common#stale(String)}
*
* ok: allow stale views
*
*/
String STALE_OK = "ok";
/**
* Constant for the value "update_after" for use with
* {@link com.cloudant.client.internal.views.CommonViewRequestBuilder#stale(String)}
*
* update_after: Allow stale views, but update them immediately after the request.
*
*/
String STALE_UPDATE_AFTER = "update_after";
/**
* Setters for parameters that are common to all view requests.
*
* @param the type of the key emitted by the view
* @param the type of the request builder returned after each set operation
* @since 2.0.0
*/
interface Common {
/**
* Return the documents in ‘descending by key’ order.
*
* @param descending {@code true} to return the documents in "descending by key" order,
* default {@code false}
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB descending(boolean descending);
/**
* Stop returning records when the specified key is reached.
*
* @param endkey of the type emitted by the view
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB endKey(K endkey);
/**
* Stop returning records when the specified document ID is reached.
*
* Used to distinguish between records with the same endkey.
*
*
* @param endkey_docid endkey document ID
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB endKeyDocId(String endkey_docid);
/**
* Include the full content of the documents in the response.
*
* Note that using include_docs=true might have
*
* performance implications.
*
*
* @param include_docs {@code true} to return the full content, default {@code false}
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
public RB includeDocs(boolean include_docs);
/**
* Include rows with the specified endkey.
*
* @param inclusive_end {@code false} to exclude, default {@code true}
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB inclusiveEnd(boolean inclusive_end);
/**
* Return only documents that match the specified key or keys.
*
* @param keys one or more keys of the type emitted by the view
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB keys(K... keys);
/**
* Allow the results from a stale view to be used. This makes the request return
* immediately, even if the view has not been completely built yet.
* If this parameter is not given, a response is returned only after the view has been
* built.
*
*
* See:
*
*
* - {@link SettableViewParameters#STALE_OK}
* - {@link SettableViewParameters#STALE_UPDATE_AFTER}
*
*
* @param stale string indicating stale view behaviour
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB stale(String stale);
/**
* Return records starting with the specified key.
*
* @param startkey of the type emitted by the view
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB startKey(K startkey);
/**
* Return records starting with the specified document ID.
*
* Used to distinguish between records with the same endkey.
*
*
* @param startkey_docid startkey document ID
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB startKeyDocId(String startkey_docid);
}
/**
* Setters for parameters applicable to views that have reduce
*
* @param the type of the key emitted by the view
* @param the type of the request builder returned after each set operation
*/
interface Reduceable {
/**
* Use the reduce function of the view.
*
* Note that although the default is {@code true} if a view does not have a reduce
* function this parameter will have no effect.
*
*
* @param reduce {@code false} to not use reduce, default {@code true}
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB reduce(boolean reduce);
/**
* Group the results to a group or single row when using a reduce function.
*
* @param group {@code true} to group, default {@code false},
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB group(boolean group);
/**
* Group reduce results for the specified number of array fields. Only applicable when
* using a complex (JSON array) key.
*
* @param group_level number of array fields to group
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB groupLevel(int group_level);
}
/**
* Setters for parameters only available to unpaginated requests.
*
* @param the type of the key emitted by the view
* @param the type of the request builder returned after each set operation
* @since 2.0.0
*/
interface Unpaginated extends Common {
/**
* Limits the number of returned rows to the specified count.
*
* Do not use skip/limit for pagination, instead use
* {@link com.cloudant.client.api.views.ViewRequestBuilder#newPaginatedRequest(Key.Type,
* Class)}
* .
*
*
* @param limit the number of results to limit to
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB limit(int limit);
/**
* Skips the specified number of rows from the start.
*
* Do not use skip/limit for pagination, instead use
* {@link com.cloudant.client.api.views.ViewRequestBuilder#newPaginatedRequest(Key.Type,
* Class)}
* .
*
*
* @param skip the number of results to skip
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB skip(long skip);
}
/**
* Setters for parameters only available to paginated requests.
*
* @param the type of the key emitted by the view
* @param the type of the request builder returned after each set operation
* @since 2.0.0
*/
interface Paginated extends Common {
/**
* Limits the number of returned rows to the specified number on each page.
*
* @param rowsPerPage the number of rows on each page; between 1 and {@link
* Integer#MAX_VALUE}-1
* @return the builder to compose additional parameters or build the request
* @since 2.0.0
*/
RB rowsPerPage(int rowsPerPage);
}
}