Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / search / checkers / CursorChecker.java
blobe1a977181ec43cd22dfdebbfba067c59b1e83481
1 // Copyright 2012 Google Inc. All Rights Reserved.
3 package com.google.appengine.api.search.checkers;
5 import com.google.apphosting.api.AppEngineInternal;
7 /**
8 * Checks values of {@link com.google.appengine.api.search.Cursor}.
11 @AppEngineInternal
12 public final class CursorChecker {
14 /**
15 * Checks the cursor string if provided is not empty nor too long.
17 * @param cursor the search cursor to check
18 * @return the checked cursor
19 * @throws IllegalArgumentException if the cursor is empty or is too long
21 public static String checkCursor(String cursor) {
22 if (cursor != null) {
23 Preconditions.checkArgument(!cursor.isEmpty(),
24 "cursor cannot be empty");
25 Preconditions.checkArgument(cursor.length() <= SearchApiLimits.MAXIMUM_CURSOR_LENGTH,
26 String.format("cursor cannot be longer than %d characters",
27 SearchApiLimits.MAXIMUM_CURSOR_LENGTH));
29 return cursor;