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;
22831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyeimport static java.lang.annotation.RetentionPolicy.CLASS;
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>
30831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * Example:
31831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * <pre>{@code
32831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  &#64;Retention(CLASS)
33831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  &#64;IntDef(&#123;NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS&#125;)
34831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  public &#64;interface NavigationMode &#123;&#125;
35831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  public static final int NAVIGATION_MODE_STANDARD = 0;
36831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  public static final int NAVIGATION_MODE_LIST = 1;
37831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  public static final int NAVIGATION_MODE_TABS = 2;
38831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  ...
39831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  public abstract void setNavigationMode(&#64;NavigationMode int mode);
40831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  &#64;NavigationMode
41831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  public abstract int getNavigationMode();
42831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * }</pre>
43831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * For a flag, set the flag attribute:
44831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * <pre>{@code
45831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *  &#64;IntDef(
46831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *      flag = true
47831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *      value = &#123;NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS&#125;)
48831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * }</pre>
49831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye *
50831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye * @hide
51831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye */
52831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye@Retention(CLASS)
53831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye@Target({ANNOTATION_TYPE})
54831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbyepublic @interface IntDef {
55831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye    /** Defines the allowed constants for this element */
56831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye    long[] value() default {};
57831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye
58831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye    /** Defines whether the constants can be used as a flag, or just as an enum (the default) */
59831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye    boolean flag() default false;
60831c5df6035b84bfcb3242c5c0a39acd7e3fd1b5Tor Norbye}
61