1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.search
.checkers
;
5 import com
.google
.appengine
.api
.search
.SearchServicePb
.ScorerSpec
;
8 * Checks the values of a {@link SortOptions}.
11 public class SortOptionsChecker
{
14 * The maximum number of documents that can be requested to be scored.
16 public static final int MAXIMUM_LIMIT
= 10000;
19 * The default number of documents to score.
21 public static final int DEFAULT_LIMIT
= 1000;
24 * Checks whether the limit on number of documents to score is between 0 and
27 * @param limit the maximum number of documents to score in the search
28 * @return the checked limit
29 * @throws IllegalArgumentException if the limit is out of range
31 public static int checkLimit(int limit
) {
32 Preconditions
.checkArgument(limit
>= 0 && limit
<= MAXIMUM_LIMIT
,
33 "The limit %d must be between 0 and %d", limit
, MAXIMUM_LIMIT
);
38 * Checks the {@link ScorerSpec} is valid, specifically checking the limit
39 * on number of documents to score is not too large.
41 * @param spec the {@link ScorerSpec} to check
42 * @return the checked spec
43 * @throws IllegalArgumentException if the spec is invalid
45 public static ScorerSpec
checkValid(ScorerSpec spec
) {
46 checkLimit(spec
.getLimit());