1/*
2 * Copyright (C) 2016 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
17package android.support.annotation;
18
19import java.lang.annotation.Documented;
20import java.lang.annotation.Retention;
21import java.lang.annotation.RetentionPolicy;
22import java.lang.annotation.Target;
23
24import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
25import static java.lang.annotation.ElementType.FIELD;
26import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
27import static java.lang.annotation.ElementType.METHOD;
28import static java.lang.annotation.ElementType.PARAMETER;
29import static java.lang.annotation.RetentionPolicy.CLASS;
30
31/**
32 * Denotes that an integer parameter, field or method return value is expected
33 * to represent a dimension.
34 */
35@Documented
36@Retention(CLASS)
37@Target({METHOD,PARAMETER,FIELD,LOCAL_VARIABLE,ANNOTATION_TYPE})
38public @interface Dimension {
39    @Unit
40    int unit() default PX;
41
42    int DP = 0;
43    int PX = 1;
44    int SP = 2;
45
46    @IntDef({PX, DP, SP})
47    @Retention(RetentionPolicy.SOURCE)
48    @interface Unit {}
49}
50