Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / search / checkers / SortExpressionChecker.java
blob5a39640845f5babf1b3cb9abde83fba99766d1e4
1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com.google.appengine.api.search.checkers;
5 import com.google.appengine.api.search.SearchServicePb.SortSpec;
7 /**
8 * Checks the values of a {@link SortExpression}.
11 public class SortExpressionChecker {
13 /**
14 * Checks the {@link ScorerSpec} is valid, specifically checking the limit
15 * on number of documents to score is not too large.
17 * @param spec the {@link ScorerSpec} to check
18 * @return the checked spec
19 * @throws IllegalArgumentException if the spec is invalid
21 public static SortSpec checkValid(SortSpec spec) {
22 Preconditions.checkArgument(
23 (!spec.hasDefaultValueText() || !spec.hasDefaultValueNumeric()),
24 "at most one of default string or numeric value can be specified");
25 if (spec.hasDefaultValueText()) {
26 FieldChecker.checkText(spec.getDefaultValueText());
28 return spec;