• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.common.api;
18 
19 import com.android.annotations.NonNull;
20 import com.android.annotations.Nullable;
21 import com.google.common.annotations.Beta;
22 
23 /**
24  * An IValidator can validate strings and return custom messages if validation
25  * fails.
26  * <p>
27  * <b>NOTE: This is not a public or final API; if you rely on this be prepared
28  * to adjust your code for the next tools release.</b>
29  */
30 @Beta
31 public interface IValidator {
32     /**
33      * Validates the given input string, and return null if the text is valid,
34      * and otherwise return a description for why the text is invalid. Returning
35      * an empty String ("") is acceptable (but should only be done when it is
36      * obvious to the user why the String is not valid.)
37      *
38      * @param text The input string to be validated
39      * @return Null if the text is valid, and otherwise a description (possibly
40      *         empty) for why the text is not valid.
41      */
42     @Nullable
validate(@onNull String text)43     String validate(@NonNull String text);
44 }
45