1831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye/* 2831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * Copyright (C) 2013 The Android Open Source Project 3831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * 4831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * Licensed under the Apache License, Version 2.0 (the "License"); 5831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * you may not use this file except in compliance with the License. 6831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * You may obtain a copy of the License at 7831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * 8831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * http://www.apache.org/licenses/LICENSE-2.0 9831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * 10831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * Unless required by applicable law or agreed to in writing, software 11831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * distributed under the License is distributed on an "AS IS" BASIS, 12831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * See the License for the specific language governing permissions and 14831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * limitations under the License. 15831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye */ 16831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyepackage android.annotation; 17831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye 18831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyeimport java.lang.annotation.Retention; 19831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyeimport java.lang.annotation.Target; 20831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye 21831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyeimport static java.lang.annotation.ElementType.ANNOTATION_TYPE; 226413795bbbbd94a9b821db9d62f409d2ae3e8c31Tor Norbyeimport static java.lang.annotation.RetentionPolicy.SOURCE; 23831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye 24831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye/** 25831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * Denotes that the annotated element of integer type, represents 26831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * a logical type and that its value should be one of the explicitly 27831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * named constants. If the {@link #flag()} attribute is set to true, 28831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * multiple constants can be combined. 29831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * <p> 3071fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * <pre><code> 3171fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * @Retention(SOURCE) 3271fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * @IntDef({NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS}) 3371fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * public @interface NavigationMode {} 34831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * public static final int NAVIGATION_MODE_STANDARD = 0; 35831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * public static final int NAVIGATION_MODE_LIST = 1; 36831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * public static final int NAVIGATION_MODE_TABS = 2; 37831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * ... 3871fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * public abstract void setNavigationMode(@NavigationMode int mode); 39831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * @NavigationMode 40831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * public abstract int getNavigationMode(); 4171fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * </code></pre> 42831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * For a flag, set the flag attribute: 4371fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * <pre><code> 44831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * @IntDef( 45a05b650098d9fe1c7a44c65b63cdf2e2b8884a70Tor Norbye * flag = true, 4671fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * value = {NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS}) 4771fbb81b14958b80fe55738607740c6630e4e9daNeil Fuller * </code></pre> 48831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * 49831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * @hide 50831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye */ 516413795bbbbd94a9b821db9d62f409d2ae3e8c31Tor Norbye@Retention(SOURCE) 52831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye@Target({ANNOTATION_TYPE}) 53831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyepublic @interface IntDef { 546503bd8e33dbf6e8357256d43c6e1158e32a0268Jeff Sharkey /** Defines the constant prefix for this element */ 555db9a911354271abdc13a2a645d0de7d2619010eJeff Sharkey String[] prefix() default {}; 565db9a911354271abdc13a2a645d0de7d2619010eJeff Sharkey /** Defines the constant suffix for this element */ 575db9a911354271abdc13a2a645d0de7d2619010eJeff Sharkey String[] suffix() default {}; 586503bd8e33dbf6e8357256d43c6e1158e32a0268Jeff Sharkey 59831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye /** Defines the allowed constants for this element */ 60f740c7ea0810c186e84e989b72012ed7152a7834Tor Norbye int[] value() default {}; 61831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye 62831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye /** Defines whether the constants can be used as a flag, or just as an enum (the default) */ 63831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye boolean flag() default false; 64831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye} 65