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.testapi;
18 
19 import static android.car.CarOccupantZoneManager.OCCUPANT_TYPE_DRIVER;
20 
21 import android.car.CarOccupantZoneManager.OccupantTypeEnum;
22 import android.car.CarOccupantZoneManager.OccupantZoneInfo;
23 import android.car.VehicleAreaSeat;
24 
25 /**
26  * Factory class used to create an instance of
27  * {@link android.car.CarOccupantZoneManager.OccupantZoneInfo} for testing purposes
28  * since the constructor is hidden.
29  */
30 public final class OccupantZoneInfoTestBuilder {
31     private int mZoneId;
32     private @OccupantTypeEnum int mOccupantType = OCCUPANT_TYPE_DRIVER;
33     private @VehicleAreaSeat.Enum int mSeat = VehicleAreaSeat.SEAT_ROW_1_LEFT;
34 
35     /**
36      * Builder used to creates an {@link android.car.CarOccupantZoneManager.OccupantZoneInfo}
37      * object of the desired state, setting {@code zoneId}, {@code occupantType}, and {@code seat}.
38      */
OccupantZoneInfoTestBuilder()39     public OccupantZoneInfoTestBuilder() {
40     }
41 
42     /**
43      * Sets the occupant {@code zoneId}
44      * of the {@link android.car.CarOccupantZoneManager.OccupantZoneInfo} object
45      */
setZoneId(int zoneId)46     public OccupantZoneInfoTestBuilder setZoneId(int zoneId) {
47         mZoneId = zoneId;
48         return this;
49     }
50     /**
51      * Sets the {@code occupantType}
52      * of the {@link android.car.CarOccupantZoneManager.OccupantZoneInfo} object
53      */
setOccupantType(@ccupantTypeEnum int occupantType)54     public OccupantZoneInfoTestBuilder setOccupantType(@OccupantTypeEnum int occupantType) {
55         mOccupantType = occupantType;
56         return this;
57     }
58     /**
59      * Sets the {@code seat}
60      * of the {@link android.car.CarOccupantZoneManager.OccupantZoneInfo} object
61      */
setSeat(@ehicleAreaSeat.Enum int seat)62     public OccupantZoneInfoTestBuilder setSeat(@VehicleAreaSeat.Enum int seat) {
63         mSeat = seat;
64         return this;
65     }
66 
67     /**
68      * Builds an {@link android.car.CarOccupantZoneManager.OccupantZoneInfo}
69      * object of the desired state, setting {@code zoneId}, {@code occupantType}, and {@code seat}.
70      */
build()71     public OccupantZoneInfo build() {
72         return new OccupantZoneInfo(mZoneId, mOccupantType, mSeat);
73     }
74 }
75