• 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     // Added AddedInOrBefore or ApiRequirement Annotation manually
53     //
54     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
55     //   Settings > Editor > Code Style > Formatter Control
56     //@formatter:off
57 
58 
59     @DataClass.Generated.Member
CarPowerPolicyFilter( @onNull int[] components)60     /* package-private */ CarPowerPolicyFilter(
61             @NonNull int[] components) {
62         this.mComponents = components;
63         AnnotationValidations.validate(
64                 NonNull.class, null, mComponents);
65 
66         // onConstructed(); // You can define this method to get a callback
67     }
68 
69     /**
70      * List of components of interest. Components are one of
71      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
72      */
73     @DataClass.Generated.Member
74     @AddedInOrBefore(majorVersion = 33)
getComponents()75     public @NonNull int[] getComponents() {
76         return mComponents;
77     }
78 
79     @Override
80     @DataClass.Generated.Member
81     @AddedInOrBefore(majorVersion = 33)
writeToParcel(@onNull android.os.Parcel dest, int flags)82     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
83         // You can override field parcelling by defining methods like:
84         // void parcelFieldName(Parcel dest, int flags) { ... }
85 
86         dest.writeIntArray(mComponents);
87     }
88 
89     @Override
90     @DataClass.Generated.Member
91     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
92     @AddedInOrBefore(majorVersion = 33)
describeContents()93     public int describeContents() { return 0; }
94 
95     /** @hide */
96     @SuppressWarnings({"unchecked", "RedundantCast"})
97     @DataClass.Generated.Member
CarPowerPolicyFilter(@onNull android.os.Parcel in)98     /* package-private */ CarPowerPolicyFilter(@NonNull android.os.Parcel in) {
99         // You can override field unparcelling by defining methods like:
100         // static FieldType unparcelFieldName(Parcel in) { ... }
101 
102         int[] components = in.createIntArray();
103 
104         this.mComponents = components;
105         AnnotationValidations.validate(
106                 NonNull.class, null, mComponents);
107 
108         // onConstructed(); // You can define this method to get a callback
109     }
110 
111     @DataClass.Generated.Member
112     @AddedInOrBefore(majorVersion = 33)
113     public static final @NonNull Parcelable.Creator<CarPowerPolicyFilter> CREATOR
114             = new Parcelable.Creator<CarPowerPolicyFilter>() {
115         @Override
116         public CarPowerPolicyFilter[] newArray(int size) {
117             return new CarPowerPolicyFilter[size];
118         }
119 
120         @Override
121         public CarPowerPolicyFilter createFromParcel(@NonNull android.os.Parcel in) {
122             return new CarPowerPolicyFilter(in);
123         }
124     };
125 
126     /**
127      * A builder for {@link CarPowerPolicyFilter}
128      */
129     @SuppressWarnings("WeakerAccess")
130     @DataClass.Generated.Member
131     public static final class Builder {
132 
133         private @NonNull int[] mComponents;
134 
135         private long mBuilderFieldsSet = 0L;
136 
Builder()137         public Builder() {
138         }
139 
140         /**
141          * List of components of interest. Components are one of
142          * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
143          */
144         @DataClass.Generated.Member
145         @AddedInOrBefore(majorVersion = 33)
setComponents(@onNull int... value)146         public @NonNull Builder setComponents(@NonNull int... value) {
147             checkNotUsed();
148             mBuilderFieldsSet |= 0x1;
149             mComponents = value;
150             return this;
151         }
152 
153         /** Builds the instance. This builder should not be touched after calling this! */
154         @AddedInOrBefore(majorVersion = 33)
build()155         public @NonNull CarPowerPolicyFilter build() {
156             checkNotUsed();
157             mBuilderFieldsSet |= 0x2; // Mark builder used
158 
159             if ((mBuilderFieldsSet & 0x1) == 0) {
160                 mComponents = new int[] {};
161             }
162             CarPowerPolicyFilter o = new CarPowerPolicyFilter(
163                     mComponents);
164             return o;
165         }
166 
checkNotUsed()167         private void checkNotUsed() {
168             if ((mBuilderFieldsSet & 0x2) != 0) {
169                 throw new IllegalStateException(
170                         "This Builder should not be reused. Use a new Builder instance instead");
171             }
172         }
173     }
174 
175     @DataClass.Generated(
176             time = 1628099142505L,
177             codegenVersion = "1.0.23",
178             sourceFile = "packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicyFilter.java",
179             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)")
180     @Deprecated
181     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()182     private void __metadata() {}
183 
184 
185     //@formatter:on
186     // End of generated code
187 
188 }
189