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
;
6 import com
.google
.apphosting
.api
.AppEngineInternal
;
9 * Checks the values of a {@link SortOptions}.
13 public class SortOptionsChecker
{
16 * Checks whether the limit on number of documents to score is between 0 and
19 * @param limit the maximum number of documents to score in the search
20 * @return the checked limit
21 * @throws IllegalArgumentException if the limit is out of range
23 public static int checkLimit(int limit
) {
24 Preconditions
.checkArgument(limit
>= 0 && limit
<= SearchApiLimits
.SEARCH_MAXIMUM_SORTED_LIMIT
,
25 "The limit %d must be between 0 and %d", limit
,
26 SearchApiLimits
.SEARCH_MAXIMUM_SORTED_LIMIT
);
31 * Checks the {@link ScorerSpec} is valid, specifically checking the limit
32 * on number of documents to score is not too large.
34 * @param spec the {@link ScorerSpec} to check
35 * @return the checked spec
36 * @throws IllegalArgumentException if the spec is invalid
38 public static ScorerSpec
checkValid(ScorerSpec spec
) {
39 checkLimit(spec
.getLimit());