1 /*
2  * Copyright (C) 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 package android.car;
17 
18 import android.annotation.IntDef;
19 
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 
23 /**
24  * List of enums for vehicle gears.
25  */
26 public final class VehicleGear {
27 
28     /**
29      *  GEAR_* represents meaning of value for {@link VehiclePropertyIds#GEAR_SELECTION} and
30      *  {@link VehiclePropertyIds#CURRENT_GEAR}. {@link VehicleGear#GEAR_PARK} and
31      *  {@link VehicleGear#GEAR_DRIVE} only apply to the {@link VehiclePropertyIds#GEAR_SELECTION}
32      *  property for a vehicle with an automatic transmission.
33      */
34     public static final int GEAR_UNKNOWN    = 0x0000;
35     public static final int GEAR_NEUTRAL    = 0x0001;
36     public static final int GEAR_REVERSE    = 0x0002;
37     public static final int GEAR_PARK       = 0x0004;
38     public static final int GEAR_DRIVE      = 0x0008;
39     public static final int GEAR_FIRST      = 0x0010;
40     public static final int GEAR_SECOND     = 0x0020;
41     public static final int GEAR_THIRD      = 0x0040;
42     public static final int GEAR_FOURTH     = 0x0080;
43     public static final int GEAR_FIFTH      = 0x0100;
44     public static final int GEAR_SIXTH      = 0x0200;
45     public static final int GEAR_SEVENTH    = 0x0400;
46     public static final int GEAR_EIGHTH     = 0x0800;
47     public static final int GEAR_NINTH      = 0x1000;
48 
49     /** @hide */
50     @Retention(RetentionPolicy.SOURCE)
51     @IntDef({
52         GEAR_UNKNOWN,
53         GEAR_NEUTRAL,
54         GEAR_REVERSE,
55         GEAR_PARK,
56         GEAR_DRIVE,
57         GEAR_FIRST,
58         GEAR_SECOND,
59         GEAR_THIRD,
60         GEAR_FOURTH,
61         GEAR_FIFTH,
62         GEAR_SIXTH,
63         GEAR_SEVENTH,
64         GEAR_EIGHTH,
65         GEAR_NINTH,
66     })
67     public @interface Enum {}
VehicleGear()68     private VehicleGear() {}
69 
70     /**
71      * @param o Integer
72      * @return String
73      */
toString(int o)74     public static  String toString(int o) {
75         if (o == GEAR_UNKNOWN) {
76             return "GEAR_UNKNOWN";
77         }
78         if (o == GEAR_NEUTRAL) {
79             return "GEAR_NEUTRAL";
80         }
81         if (o == GEAR_REVERSE) {
82             return "GEAR_REVERSE";
83         }
84         if (o == GEAR_PARK) {
85             return "GEAR_PARK";
86         }
87         if (o == GEAR_DRIVE) {
88             return "GEAR_DRIVE";
89         }
90         if (o == GEAR_FIRST) {
91             return "GEAR_FIRST";
92         }
93         if (o == GEAR_SECOND) {
94             return "GEAR_SECOND";
95         }
96         if (o == GEAR_THIRD) {
97             return "GEAR_THIRD";
98         }
99         if (o == GEAR_FOURTH) {
100             return "GEAR_FOURTH";
101         }
102         if (o == GEAR_FIFTH) {
103             return "GEAR_FIFTH";
104         }
105         if (o == GEAR_SIXTH) {
106             return "GEAR_SIXTH";
107         }
108         if (o == GEAR_SEVENTH) {
109             return "GEAR_SEVENTH";
110         }
111         if (o == GEAR_EIGHTH) {
112             return "GEAR_EIGHTH";
113         }
114         if (o == GEAR_NINTH) {
115             return "GEAR_NINTH";
116         }
117         return "0x" + Integer.toHexString(o);
118     }
119 }
120