175aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye/* 275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * Copyright (C) 2014 The Android Open Source Project 375aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * 475aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * Licensed under the Apache License, Version 2.0 (the "License"); 575aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * you may not use this file except in compliance with the License. 675aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * You may obtain a copy of the License at 775aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * 875aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * http://www.apache.org/licenses/LICENSE-2.0 975aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * 1075aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * Unless required by applicable law or agreed to in writing, software 1175aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * distributed under the License is distributed on an "AS IS" BASIS, 1275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1375aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * See the License for the specific language governing permissions and 1475aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * limitations under the License. 1575aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye */ 1675aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyepackage android.support.annotation; 1775aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye 1875aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport java.lang.annotation.Retention; 1975aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport java.lang.annotation.RetentionPolicy; 2075aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport java.lang.annotation.Target; 2175aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye 2275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport static java.lang.annotation.ElementType.ANNOTATION_TYPE; 2375aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport static java.lang.annotation.ElementType.FIELD; 2475aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport static java.lang.annotation.ElementType.METHOD; 2575aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport static java.lang.annotation.ElementType.PARAMETER; 2675aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyeimport static java.lang.annotation.RetentionPolicy.SOURCE; 2775aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye 2875aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye/** 2975aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * Denotes that the annotated element of integer type, represents 3075aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * a logical type and that its value should be one of the explicitly 311c086e1e7849c0b3fe31d11ea83d42bd78abcd6dXavier Ducrohet * named constants. If the IntDef#flag() attribute is set to true, 3275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * multiple constants can be combined. 3375aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * <p> 3475aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * Example: 3575aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * <pre>{@code 36d793fe09e20e5a13fcdfb685d45ee19768723210Jeff Davidson * @Retention(SOURCE) 3775aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * @IntDef({NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS}) 3875aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * public @interface NavigationMode {} 3975aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * public static final int NAVIGATION_MODE_STANDARD = 0; 4075aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * public static final int NAVIGATION_MODE_LIST = 1; 4175aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * public static final int NAVIGATION_MODE_TABS = 2; 4275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * ... 4375aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * public abstract void setNavigationMode(@NavigationMode int mode); 4475aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * @NavigationMode 4575aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * public abstract int getNavigationMode(); 4675aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * }</pre> 4775aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * For a flag, set the flag attribute: 4875aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * <pre>{@code 4975aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * @IntDef( 5075aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * flag = true 5175aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * value = {NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS}) 5275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye * }</pre> 5375aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye */ 549b2e27b330a5047774442f112efd8ba40b046c39Tor Norbye@Retention(SOURCE) 5575aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye@Target({ANNOTATION_TYPE}) 5675aea14c26565d3fde46c4ce410f5c384c42162cTor Norbyepublic @interface IntDef { 5775aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye /** Defines the allowed constants for this element */ 5875aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye long[] value() default {}; 5975aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye 6075aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye /** Defines whether the constants can be used as a flag, or just as an enum (the default) */ 6175aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye boolean flag() default false; 6275aea14c26565d3fde46c4ce410f5c384c42162cTor Norbye} 63