1 /*
2  * Copyright (C) 2017 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.vms;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 import android.util.ArraySet;
24 
25 import com.android.internal.util.DataClass;
26 
27 import java.util.Collections;
28 import java.util.Objects;
29 import java.util.Set;
30 
31 /**
32  * Layer dependencies for single Vehicle Map Service layer.
33  *
34  * Dependencies are treated as <b>hard</b> dependencies, meaning that an offered layer will not be
35  * reported as available until all dependent layers are also available.
36  *
37  * @hide
38  */
39 @SystemApi
40 @DataClass(genAidl = true, genEqualsHashCode = true, genToString = true)
41 public final class VmsLayerDependency implements Parcelable {
42     /**
43      * Layer that has dependencies
44      */
45     private final @NonNull VmsLayer mLayer;
46 
47     /**
48      * Layers that the given layer depends on
49      */
50     private @NonNull Set<VmsLayer> mDependencies;
51 
onConstructed()52     private void onConstructed() {
53         mDependencies = Collections.unmodifiableSet(mDependencies);
54     }
55 
parcelDependencies(Parcel dest, int flags)56     private void parcelDependencies(Parcel dest, int flags) {
57         dest.writeArraySet(new ArraySet<>(mDependencies));
58     }
59 
60     @SuppressWarnings("unchecked")
unparcelDependencies(Parcel in)61     private Set<VmsLayer> unparcelDependencies(Parcel in) {
62         return (Set<VmsLayer>) in.readArraySet(VmsLayer.class.getClassLoader());
63     }
64 
65     /**
66      * Creates a new VmsLayerDependency without dependencies.
67      *
68      * @param layer
69      *   Layer that has no dependencies
70      */
VmsLayerDependency(@onNull VmsLayer layer)71     public VmsLayerDependency(@NonNull VmsLayer layer) {
72         this(layer, Collections.emptySet());
73     }
74 
75 
76 
77     // Code below generated by codegen v1.0.14.
78     //
79     // DO NOT MODIFY!
80     // CHECKSTYLE:OFF Generated code
81     //
82     // To regenerate run:
83     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/vms/VmsLayerDependency.java
84     //
85     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
86     //   Settings > Editor > Code Style > Formatter Control
87     //@formatter:off
88 
89 
90     /**
91      * Creates a new VmsLayerDependency.
92      *
93      * @param layer
94      *   Layer that has dependencies
95      * @param dependencies
96      *   Layers that the given layer depends on
97      */
98     @DataClass.Generated.Member
VmsLayerDependency( @onNull VmsLayer layer, @NonNull Set<VmsLayer> dependencies)99     public VmsLayerDependency(
100             @NonNull VmsLayer layer,
101             @NonNull Set<VmsLayer> dependencies) {
102         this.mLayer = layer;
103         com.android.internal.util.AnnotationValidations.validate(
104                 NonNull.class, null, mLayer);
105         this.mDependencies = dependencies;
106         com.android.internal.util.AnnotationValidations.validate(
107                 NonNull.class, null, mDependencies);
108 
109         onConstructed();
110     }
111 
112     /**
113      * Layer that has dependencies
114      */
115     @DataClass.Generated.Member
getLayer()116     public @NonNull VmsLayer getLayer() {
117         return mLayer;
118     }
119 
120     /**
121      * Layers that the given layer depends on
122      */
123     @DataClass.Generated.Member
getDependencies()124     public @NonNull Set<VmsLayer> getDependencies() {
125         return mDependencies;
126     }
127 
128     @Override
129     @DataClass.Generated.Member
toString()130     public String toString() {
131         // You can override field toString logic by defining methods like:
132         // String fieldNameToString() { ... }
133 
134         return "VmsLayerDependency { " +
135                 "layer = " + mLayer + ", " +
136                 "dependencies = " + mDependencies +
137         " }";
138     }
139 
140     @Override
141     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)142     public boolean equals(@android.annotation.Nullable Object o) {
143         // You can override field equality logic by defining either of the methods like:
144         // boolean fieldNameEquals(VmsLayerDependency other) { ... }
145         // boolean fieldNameEquals(FieldType otherValue) { ... }
146 
147         if (this == o) return true;
148         if (o == null || getClass() != o.getClass()) return false;
149         @SuppressWarnings("unchecked")
150         VmsLayerDependency that = (VmsLayerDependency) o;
151         //noinspection PointlessBooleanExpression
152         return true
153                 && Objects.equals(mLayer, that.mLayer)
154                 && Objects.equals(mDependencies, that.mDependencies);
155     }
156 
157     @Override
158     @DataClass.Generated.Member
hashCode()159     public int hashCode() {
160         // You can override field hashCode logic by defining methods like:
161         // int fieldNameHashCode() { ... }
162 
163         int _hash = 1;
164         _hash = 31 * _hash + Objects.hashCode(mLayer);
165         _hash = 31 * _hash + Objects.hashCode(mDependencies);
166         return _hash;
167     }
168 
169     @Override
170     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)171     public void writeToParcel(@NonNull Parcel dest, int flags) {
172         // You can override field parcelling by defining methods like:
173         // void parcelFieldName(Parcel dest, int flags) { ... }
174 
175         dest.writeTypedObject(mLayer, flags);
176         parcelDependencies(dest, flags);
177     }
178 
179     @Override
180     @DataClass.Generated.Member
describeContents()181     public int describeContents() { return 0; }
182 
183     /** @hide */
184     @SuppressWarnings({"unchecked", "RedundantCast"})
185     @DataClass.Generated.Member
VmsLayerDependency(@onNull Parcel in)186     /* package-private */ VmsLayerDependency(@NonNull Parcel in) {
187         // You can override field unparcelling by defining methods like:
188         // static FieldType unparcelFieldName(Parcel in) { ... }
189 
190         VmsLayer layer = (VmsLayer) in.readTypedObject(VmsLayer.CREATOR);
191         Set<VmsLayer> dependencies = unparcelDependencies(in);
192 
193         this.mLayer = layer;
194         com.android.internal.util.AnnotationValidations.validate(
195                 NonNull.class, null, mLayer);
196         this.mDependencies = dependencies;
197         com.android.internal.util.AnnotationValidations.validate(
198                 NonNull.class, null, mDependencies);
199 
200         onConstructed();
201     }
202 
203     @DataClass.Generated.Member
204     public static final @NonNull Parcelable.Creator<VmsLayerDependency> CREATOR
205             = new Parcelable.Creator<VmsLayerDependency>() {
206         @Override
207         public VmsLayerDependency[] newArray(int size) {
208             return new VmsLayerDependency[size];
209         }
210 
211         @Override
212         public VmsLayerDependency createFromParcel(@NonNull Parcel in) {
213             return new VmsLayerDependency(in);
214         }
215     };
216 
217     @DataClass.Generated(
218             time = 1582065875835L,
219             codegenVersion = "1.0.14",
220             sourceFile = "packages/services/Car/car-lib/src/android/car/vms/VmsLayerDependency.java",
221             inputSignatures = "private final @android.annotation.NonNull android.car.vms.VmsLayer mLayer\nprivate @android.annotation.NonNull java.util.Set<android.car.vms.VmsLayer> mDependencies\nprivate  void onConstructed()\nprivate  void parcelDependencies(android.os.Parcel,int)\nprivate @java.lang.SuppressWarnings(\"unchecked\") java.util.Set<android.car.vms.VmsLayer> unparcelDependencies(android.os.Parcel)\nclass VmsLayerDependency extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=true, genEqualsHashCode=true, genToString=true)")
222     @Deprecated
__metadata()223     private void __metadata() {}
224 
225 
226     //@formatter:on
227     // End of generated code
228 
229 }
230