1 /* 2 * Copyright 2019 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 17 @file:Suppress("DEPRECATED_JAVA_ANNOTATION") 18 19 package androidx.annotation 20 21 import java.lang.annotation.ElementType 22 import kotlin.annotation.Retention 23 import kotlin.annotation.Target 24 import kotlin.reflect.KClass 25 26 /** 27 * Allows use of an opt-in API denoted by the given markers in the annotated file, declaration, or 28 * expression. If a declaration is annotated with [OptIn], its usages are **not** required to opt-in 29 * to that API. 30 */ 31 @Retention(AnnotationRetention.BINARY) 32 @Target( 33 AnnotationTarget.CLASS, 34 AnnotationTarget.PROPERTY, 35 AnnotationTarget.LOCAL_VARIABLE, 36 AnnotationTarget.VALUE_PARAMETER, 37 AnnotationTarget.CONSTRUCTOR, 38 AnnotationTarget.FUNCTION, 39 AnnotationTarget.PROPERTY_GETTER, 40 AnnotationTarget.PROPERTY_SETTER, 41 AnnotationTarget.FILE, 42 AnnotationTarget.TYPEALIAS 43 ) 44 @java.lang.annotation.Target( 45 ElementType.CONSTRUCTOR, 46 ElementType.FIELD, 47 ElementType.LOCAL_VARIABLE, 48 ElementType.METHOD, 49 ElementType.PACKAGE, 50 ElementType.TYPE, 51 ) 52 public annotation class OptIn( 53 /** Defines the opt-in API(s) whose usage this annotation allows. */ 54 @get:Suppress("ArrayReturn") // Kotlin generates a raw array for annotation vararg 55 vararg val markerClass: KClass<out Annotation> 56 ) 57