12f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye/*
22f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * Copyright (C) 2016 The Android Open Source Project
32f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye *
42f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * Licensed under the Apache License, Version 2.0 (the "License");
52f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * you may not use this file except in compliance with the License.
62f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * You may obtain a copy of the License at
72f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye *
82f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye *      http://www.apache.org/licenses/LICENSE-2.0
92f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye *
102f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * Unless required by applicable law or agreed to in writing, software
112f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * distributed under the License is distributed on an "AS IS" BASIS,
122f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * See the License for the specific language governing permissions and
142f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * limitations under the License.
152f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye */
162f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyepackage android.support.annotation;
172f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye
182f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyeimport java.lang.annotation.Retention;
192f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyeimport java.lang.annotation.Target;
202f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye
212f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyeimport static java.lang.annotation.ElementType.CONSTRUCTOR;
222f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyeimport static java.lang.annotation.ElementType.FIELD;
232f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyeimport static java.lang.annotation.ElementType.METHOD;
249c2b340df88ac4b88bb3e78ae0fd2c844e8f1f15Tor Norbyeimport static java.lang.annotation.ElementType.TYPE;
259c2b340df88ac4b88bb3e78ae0fd2c844e8f1f15Tor Norbye
262f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyeimport static java.lang.annotation.RetentionPolicy.CLASS;
272f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye
282f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye/**
292f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * Denotes that the annotated element should only be called on the given API level
302f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * or higher.
312f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * <p>
322f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * This is similar in purpose to the older {@code @TargetApi} annotation, but more
332f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * clearly expresses that this is a requirement on the caller, rather than being
342f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye * used to "suppress" warnings within the method that exceed the {@code minSdkVersion}.
352f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye */
362f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye@Retention(CLASS)
379c2b340df88ac4b88bb3e78ae0fd2c844e8f1f15Tor Norbye@Target({TYPE,METHOD,CONSTRUCTOR,FIELD})
382f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbyepublic @interface RequiresApi {
392e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye    /**
402e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye     * The API level to require. Alias for {@link #api} which allows you to leave out the
412e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye     * {@code api=} part.
422e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye     */
432f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye    @IntRange(from=1)
442e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye    int value() default 1;
452e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye
462e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye    /** The API level to require */
472e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye    @IntRange(from=1)
482e8f895f0c6633fa6b01c9a59c4fe9c176421bb5Tor Norbye    int api() default 1;
492f677a313ed35f25fd366e48dd9fcd65891d6efaTor Norbye}
50