1 /*
2  * Copyright (C) 2023 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 package android.car.hardware.property;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.SystemApi;
22 
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.RetentionPolicy;
25 
26 /**
27  * Used to enumerate the current state of {@link android.car.VehiclePropertyIds#TRAILER_PRESENT}.
28  *
29  * @hide
30  */
31 @SystemApi
32 public final class TrailerState {
33 
34     /**
35      * This state is used as an alternative for any {@code TrailerState} value that is not defined
36      * in the platform. Ideally, implementations of {@link
37      * android.car.VehiclePropertyIds#TRAILER_PRESENT} should not use this state. The framework can
38      * use this field to remain backwards compatible if {@code TrailerState} is extended to include
39      * additional states.
40      */
41     public static final int STATE_UNKNOWN = 0;
42 
43     /**
44      * A trailer is not attached to the vehicle.
45      */
46     public static final int STATE_NOT_PRESENT = 1;
47 
48     /**
49      * A trailer is attached to the vehicle.
50      */
51     public static final int STATE_PRESENT = 2;
52 
53     /**
54      * The state of the trailer is not available due to an error.
55      */
56     public static final int STATE_ERROR = 3;
57 
TrailerState()58     private TrailerState() {}
59 
60     /**
61      * Returns a user-friendly representation of a {@code TrailerState}.
62      */
63     @NonNull
toString( @railerStateInt int trailerState)64     public static String toString(
65             @TrailerStateInt int trailerState) {
66         switch (trailerState) {
67             case STATE_UNKNOWN:
68                 return "STATE_UNKNOWN";
69             case STATE_NOT_PRESENT:
70                 return "STATE_NOT_PRESENT";
71             case STATE_PRESENT:
72                 return "STATE_PRESENT";
73             case STATE_ERROR:
74                 return "STATE_ERROR";
75             default:
76                 return "0x" + Integer.toHexString(trailerState);
77         }
78     }
79 
80     /** @hide */
81     @IntDef({STATE_UNKNOWN, STATE_NOT_PRESENT, STATE_PRESENT, STATE_ERROR})
82     @Retention(RetentionPolicy.SOURCE)
83     public @interface TrailerStateInt {}
84 }
85 
86