• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.power;
18 
19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE;
20 
21 import android.annotation.NonNull;
22 import android.car.annotation.AddedInOrBefore;
23 import android.os.Parcelable;
24 
25 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport;
26 import com.android.car.internal.util.AnnotationValidations;
27 import com.android.car.internal.util.DataClass;
28 
29 /**
30  * Filter to receive power policy changes that a listener is interested in.
31  *
32  * For the record: When running codegen, auto-generated constructor of {@link Builder} which takes
33  * one argument should be removed manually, so that we can use the default constructor.
34  */
35 @DataClass(genBuilder = true)
36 public final class CarPowerPolicyFilter implements Parcelable {
37     /**
38      * List of components of interest. Components are one of
39      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
40      */
41     private @NonNull int[] mComponents = new int[]{};
42 
43 
44 
45     // Code below generated by codegen v1.0.23.
46     //
47     // DO NOT MODIFY!
48     // CHECKSTYLE:OFF Generated code
49     //
50     // To regenerate run:
51     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicyFilter.java
52     //
53     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
54     //   Settings > Editor > Code Style > Formatter Control
55     //@formatter:off
56 
57 
58     @DataClass.Generated.Member
CarPowerPolicyFilter( @onNull int[] components)59     /* package-private */ CarPowerPolicyFilter(
60             @NonNull int[] components) {
61         this.mComponents = components;
62         AnnotationValidations.validate(
63                 NonNull.class, null, mComponents);
64 
65         // onConstructed(); // You can define this method to get a callback
66     }
67 
68     /**
69      * List of components of interest. Components are one of
70      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
71      */
72     @DataClass.Generated.Member
73     @AddedInOrBefore(majorVersion = 33)
getComponents()74     public @NonNull int[] getComponents() {
75         return mComponents;
76     }
77 
78     @Override
79     @DataClass.Generated.Member
80     @AddedInOrBefore(majorVersion = 33)
writeToParcel(@onNull android.os.Parcel dest, int flags)81     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
82         // You can override field parcelling by defining methods like:
83         // void parcelFieldName(Parcel dest, int flags) { ... }
84 
85         dest.writeIntArray(mComponents);
86     }
87 
88     @Override
89     @DataClass.Generated.Member
90     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
91     @AddedInOrBefore(majorVersion = 33)
describeContents()92     public int describeContents() { return 0; }
93 
94     /** @hide */
95     @SuppressWarnings({"unchecked", "RedundantCast"})
96     @DataClass.Generated.Member
CarPowerPolicyFilter(@onNull android.os.Parcel in)97     /* package-private */ CarPowerPolicyFilter(@NonNull android.os.Parcel in) {
98         // You can override field unparcelling by defining methods like:
99         // static FieldType unparcelFieldName(Parcel in) { ... }
100 
101         int[] components = in.createIntArray();
102 
103         this.mComponents = components;
104         AnnotationValidations.validate(
105                 NonNull.class, null, mComponents);
106 
107         // onConstructed(); // You can define this method to get a callback
108     }
109 
110     @DataClass.Generated.Member
111     @AddedInOrBefore(majorVersion = 33)
112     public static final @NonNull Parcelable.Creator<CarPowerPolicyFilter> CREATOR
113             = new Parcelable.Creator<CarPowerPolicyFilter>() {
114         @Override
115         public CarPowerPolicyFilter[] newArray(int size) {
116             return new CarPowerPolicyFilter[size];
117         }
118 
119         @Override
120         public CarPowerPolicyFilter createFromParcel(@NonNull android.os.Parcel in) {
121             return new CarPowerPolicyFilter(in);
122         }
123     };
124 
125     /**
126      * A builder for {@link CarPowerPolicyFilter}
127      */
128     @SuppressWarnings("WeakerAccess")
129     @DataClass.Generated.Member
130     public static final class Builder {
131 
132         private @NonNull int[] mComponents;
133 
134         private long mBuilderFieldsSet = 0L;
135 
Builder()136         public Builder() {
137         }
138 
139         /**
140          * List of components of interest. Components are one of
141          * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
142          */
143         @DataClass.Generated.Member
144         @AddedInOrBefore(majorVersion = 33)
setComponents(@onNull int... value)145         public @NonNull Builder setComponents(@NonNull int... value) {
146             checkNotUsed();
147             mBuilderFieldsSet |= 0x1;
148             mComponents = value;
149             return this;
150         }
151 
152         /** Builds the instance. This builder should not be touched after calling this! */
153         @AddedInOrBefore(majorVersion = 33)
build()154         public @NonNull CarPowerPolicyFilter build() {
155             checkNotUsed();
156             mBuilderFieldsSet |= 0x2; // Mark builder used
157 
158             if ((mBuilderFieldsSet & 0x1) == 0) {
159                 mComponents = new int[] {};
160             }
161             CarPowerPolicyFilter o = new CarPowerPolicyFilter(
162                     mComponents);
163             return o;
164         }
165 
checkNotUsed()166         private void checkNotUsed() {
167             if ((mBuilderFieldsSet & 0x2) != 0) {
168                 throw new IllegalStateException(
169                         "This Builder should not be reused. Use a new Builder instance instead");
170             }
171         }
172     }
173 
174     @DataClass.Generated(
175             time = 1628099142505L,
176             codegenVersion = "1.0.23",
177             sourceFile = "packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicyFilter.java",
178             inputSignatures = "private @android.annotation.NonNull int[] mComponents\nclass CarPowerPolicyFilter extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genBuilder=true)")
179     @Deprecated
180     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()181     private void __metadata() {}
182 
183 
184     //@formatter:on
185     // End of generated code
186 
187 }
188