1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 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 package android.annotation; 17 18 import java.lang.annotation.Retention; 19 import java.lang.annotation.Target; 20 21 import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 22 import static java.lang.annotation.RetentionPolicy.SOURCE; 23 24 /** 25 * Denotes that the annotated long element represents 26 * a logical type and that its value should be one of the explicitly 27 * named constants. If the {@link #flag()} attribute is set to true, 28 * multiple constants can be combined. 29 * <p> 30 * <pre><code> 31 * @Retention(SOURCE) 32 * @LongDef({NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS}) 33 * public @interface NavigationMode {} 34 * public static final long NAVIGATION_MODE_STANDARD = 0; 35 * public static final long NAVIGATION_MODE_LIST = 1; 36 * public static final long NAVIGATION_MODE_TABS = 2; 37 * ... 38 * public abstract void setNavigationMode(@NavigationMode long mode); 39 * @NavigationMode 40 * public abstract long getNavigationMode(); 41 * </code></pre> 42 * For a flag, set the flag attribute: 43 * <pre><code> 44 * @LongDef( 45 * flag = true, 46 * value = {NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS}) 47 * </code></pre> 48 * 49 * @hide 50 */ 51 @Retention(SOURCE) 52 @Target({ANNOTATION_TYPE}) 53 public @interface LongDef { 54 /** Defines the constant prefix for this element */ prefix()55 String[] prefix() default ""; 56 57 /** Defines the allowed constants for this element */ value()58 long[] value() default {}; 59 60 /** Defines whether the constants can be used as a flag, or just as an enum (the default) */ flag()61 boolean flag() default false; 62 } 63