19c84d01adb0d1dcd63490a134004db139855477bGustav Sennton/*
29c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * Copyright 2018 The Android Open Source Project
39c84d01adb0d1dcd63490a134004db139855477bGustav Sennton *
49c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * Licensed under the Apache License, Version 2.0 (the "License");
59c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * you may not use this file except in compliance with the License.
69c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * You may obtain a copy of the License at
79c84d01adb0d1dcd63490a134004db139855477bGustav Sennton *
89c84d01adb0d1dcd63490a134004db139855477bGustav Sennton *      http://www.apache.org/licenses/LICENSE-2.0
99c84d01adb0d1dcd63490a134004db139855477bGustav Sennton *
109c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * Unless required by applicable law or agreed to in writing, software
119c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * distributed under the License is distributed on an "AS IS" BASIS,
129c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * See the License for the specific language governing permissions and
149c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * limitations under the License.
159c84d01adb0d1dcd63490a134004db139855477bGustav Sennton */
169c84d01adb0d1dcd63490a134004db139855477bGustav Senntonpackage androidx.annotation;
179c84d01adb0d1dcd63490a134004db139855477bGustav Sennton
189c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport static java.lang.annotation.ElementType.CONSTRUCTOR;
199c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport static java.lang.annotation.ElementType.FIELD;
209c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport static java.lang.annotation.ElementType.METHOD;
219c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport static java.lang.annotation.ElementType.TYPE;
229c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport static java.lang.annotation.RetentionPolicy.SOURCE;
239c84d01adb0d1dcd63490a134004db139855477bGustav Sennton
249c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport java.lang.annotation.Retention;
259c84d01adb0d1dcd63490a134004db139855477bGustav Senntonimport java.lang.annotation.Target;
269c84d01adb0d1dcd63490a134004db139855477bGustav Sennton
279c84d01adb0d1dcd63490a134004db139855477bGustav Sennton/**
289c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * Denotes that the annotated element requires one or more features. This is used to auto-generate
299c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * documentation, and more importantly: to ensure correct usage in application code, where lint and
309c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * Android Studio can check that calls marked with this annotation is surrounded by has-feature
319c84d01adb0d1dcd63490a134004db139855477bGustav Sennton * calls, referenced via the {@link RequiresFeature#enforcement()} attribute.
329c84d01adb0d1dcd63490a134004db139855477bGustav Sennton */
339c84d01adb0d1dcd63490a134004db139855477bGustav Sennton@Retention(SOURCE)
349c84d01adb0d1dcd63490a134004db139855477bGustav Sennton@Target({TYPE, FIELD, METHOD, CONSTRUCTOR})
359c84d01adb0d1dcd63490a134004db139855477bGustav Senntonpublic @interface RequiresFeature {
369c84d01adb0d1dcd63490a134004db139855477bGustav Sennton    /**
379c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     * The name of the feature that is required.
389c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     */
399c84d01adb0d1dcd63490a134004db139855477bGustav Sennton    String name();
409c84d01adb0d1dcd63490a134004db139855477bGustav Sennton
419c84d01adb0d1dcd63490a134004db139855477bGustav Sennton    /**
429c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     * Defines the name of the method that should be called to check whether the feature is
439c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     * available, using the same signature format as javadoc.
449c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     * The feature checking method can have multiple parameters, but the feature name parameter must
459c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     * be of type String and must also be the first String-type parameter.
469c84d01adb0d1dcd63490a134004db139855477bGustav Sennton     */
479c84d01adb0d1dcd63490a134004db139855477bGustav Sennton    String enforcement();
489c84d01adb0d1dcd63490a134004db139855477bGustav Sennton}
49