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  * Subscription state of Vehicle Map Service layers.
33  *
34  * The subscription state is used by publishers to determine which layers to publish data for, as
35  * any data published to a layer without subscribers will be dropped by the Vehicle Map Service.
36  *
37  * Sequence numbers are used to indicate the succession of subscription states, and increase
38  * monotonically with each change in subscriptions. They must be used by clients to ignore states
39  * that are received out-of-order.
40  *
41  * @hide
42  */
43 @SystemApi
44 @DataClass(genAidl = true, genEqualsHashCode = true, genToString = true)
45 public final class VmsSubscriptionState implements Parcelable {
46     /**
47      * Sequence number of the subscription state
48      */
49     private final int mSequenceNumber;
50 
51     /**
52      * Layers with subscriptions to all publishers
53      */
54     private @NonNull Set<VmsLayer> mLayers;
55 
56     /**
57      * Layers with subscriptions to a subset of publishers
58      */
59     private @NonNull Set<VmsAssociatedLayer> mAssociatedLayers;
60 
onConstructed()61     private void onConstructed() {
62         mLayers = Collections.unmodifiableSet(mLayers);
63         mAssociatedLayers = Collections.unmodifiableSet(mAssociatedLayers);
64     }
65 
parcelLayers(Parcel dest, int flags)66     private void parcelLayers(Parcel dest, int flags) {
67         dest.writeArraySet(new ArraySet<>(mLayers));
68     }
69 
70     @SuppressWarnings("unchecked")
unparcelLayers(Parcel in)71     private Set<VmsLayer> unparcelLayers(Parcel in) {
72         return (Set<VmsLayer>) in.readArraySet(VmsLayer.class.getClassLoader());
73     }
74 
parcelAssociatedLayers(Parcel dest, int flags)75     private void parcelAssociatedLayers(Parcel dest, int flags) {
76         dest.writeArraySet(new ArraySet<>(mAssociatedLayers));
77     }
78 
79     @SuppressWarnings("unchecked")
unparcelAssociatedLayers(Parcel in)80     private Set<VmsAssociatedLayer> unparcelAssociatedLayers(Parcel in) {
81         return (Set<VmsAssociatedLayer>) in.readArraySet(VmsAssociatedLayer.class.getClassLoader());
82     }
83 
84 
85 
86     // Code below generated by codegen v1.0.14.
87     //
88     // DO NOT MODIFY!
89     // CHECKSTYLE:OFF Generated code
90     //
91     // To regenerate run:
92     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/vms/VmsSubscriptionState.java
93     //
94     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
95     //   Settings > Editor > Code Style > Formatter Control
96     //@formatter:off
97 
98 
99     /**
100      * Creates a new VmsSubscriptionState.
101      *
102      * @param sequenceNumber
103      *   Sequence number of the subscription state
104      * @param layers
105      *   Layers with subscriptions to all publishers
106      * @param associatedLayers
107      *   Layers with subscriptions to a subset of publishers
108      */
109     @DataClass.Generated.Member
VmsSubscriptionState( int sequenceNumber, @NonNull Set<VmsLayer> layers, @NonNull Set<VmsAssociatedLayer> associatedLayers)110     public VmsSubscriptionState(
111             int sequenceNumber,
112             @NonNull Set<VmsLayer> layers,
113             @NonNull Set<VmsAssociatedLayer> associatedLayers) {
114         this.mSequenceNumber = sequenceNumber;
115         this.mLayers = layers;
116         com.android.internal.util.AnnotationValidations.validate(
117                 NonNull.class, null, mLayers);
118         this.mAssociatedLayers = associatedLayers;
119         com.android.internal.util.AnnotationValidations.validate(
120                 NonNull.class, null, mAssociatedLayers);
121 
122         onConstructed();
123     }
124 
125     /**
126      * Sequence number of the subscription state
127      */
128     @DataClass.Generated.Member
getSequenceNumber()129     public int getSequenceNumber() {
130         return mSequenceNumber;
131     }
132 
133     /**
134      * Layers with subscriptions to all publishers
135      */
136     @DataClass.Generated.Member
getLayers()137     public @NonNull Set<VmsLayer> getLayers() {
138         return mLayers;
139     }
140 
141     /**
142      * Layers with subscriptions to a subset of publishers
143      */
144     @DataClass.Generated.Member
getAssociatedLayers()145     public @NonNull Set<VmsAssociatedLayer> getAssociatedLayers() {
146         return mAssociatedLayers;
147     }
148 
149     @Override
150     @DataClass.Generated.Member
toString()151     public String toString() {
152         // You can override field toString logic by defining methods like:
153         // String fieldNameToString() { ... }
154 
155         return "VmsSubscriptionState { " +
156                 "sequenceNumber = " + mSequenceNumber + ", " +
157                 "layers = " + mLayers + ", " +
158                 "associatedLayers = " + mAssociatedLayers +
159         " }";
160     }
161 
162     @Override
163     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)164     public boolean equals(@android.annotation.Nullable Object o) {
165         // You can override field equality logic by defining either of the methods like:
166         // boolean fieldNameEquals(VmsSubscriptionState other) { ... }
167         // boolean fieldNameEquals(FieldType otherValue) { ... }
168 
169         if (this == o) return true;
170         if (o == null || getClass() != o.getClass()) return false;
171         @SuppressWarnings("unchecked")
172         VmsSubscriptionState that = (VmsSubscriptionState) o;
173         //noinspection PointlessBooleanExpression
174         return true
175                 && mSequenceNumber == that.mSequenceNumber
176                 && Objects.equals(mLayers, that.mLayers)
177                 && Objects.equals(mAssociatedLayers, that.mAssociatedLayers);
178     }
179 
180     @Override
181     @DataClass.Generated.Member
hashCode()182     public int hashCode() {
183         // You can override field hashCode logic by defining methods like:
184         // int fieldNameHashCode() { ... }
185 
186         int _hash = 1;
187         _hash = 31 * _hash + mSequenceNumber;
188         _hash = 31 * _hash + Objects.hashCode(mLayers);
189         _hash = 31 * _hash + Objects.hashCode(mAssociatedLayers);
190         return _hash;
191     }
192 
193     @Override
194     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)195     public void writeToParcel(@NonNull Parcel dest, int flags) {
196         // You can override field parcelling by defining methods like:
197         // void parcelFieldName(Parcel dest, int flags) { ... }
198 
199         dest.writeInt(mSequenceNumber);
200         parcelLayers(dest, flags);
201         parcelAssociatedLayers(dest, flags);
202     }
203 
204     @Override
205     @DataClass.Generated.Member
describeContents()206     public int describeContents() { return 0; }
207 
208     /** @hide */
209     @SuppressWarnings({"unchecked", "RedundantCast"})
210     @DataClass.Generated.Member
VmsSubscriptionState(@onNull Parcel in)211     /* package-private */ VmsSubscriptionState(@NonNull Parcel in) {
212         // You can override field unparcelling by defining methods like:
213         // static FieldType unparcelFieldName(Parcel in) { ... }
214 
215         int sequenceNumber = in.readInt();
216         Set<VmsLayer> layers = unparcelLayers(in);
217         Set<VmsAssociatedLayer> associatedLayers = unparcelAssociatedLayers(in);
218 
219         this.mSequenceNumber = sequenceNumber;
220         this.mLayers = layers;
221         com.android.internal.util.AnnotationValidations.validate(
222                 NonNull.class, null, mLayers);
223         this.mAssociatedLayers = associatedLayers;
224         com.android.internal.util.AnnotationValidations.validate(
225                 NonNull.class, null, mAssociatedLayers);
226 
227         onConstructed();
228     }
229 
230     @DataClass.Generated.Member
231     public static final @NonNull Parcelable.Creator<VmsSubscriptionState> CREATOR
232             = new Parcelable.Creator<VmsSubscriptionState>() {
233         @Override
234         public VmsSubscriptionState[] newArray(int size) {
235             return new VmsSubscriptionState[size];
236         }
237 
238         @Override
239         public VmsSubscriptionState createFromParcel(@NonNull Parcel in) {
240             return new VmsSubscriptionState(in);
241         }
242     };
243 
244     @DataClass.Generated(
245             time = 1582061018243L,
246             codegenVersion = "1.0.14",
247             sourceFile = "packages/services/Car/car-lib/src/android/car/vms/VmsSubscriptionState.java",
248             inputSignatures = "private final  int mSequenceNumber\nprivate @android.annotation.NonNull java.util.Set<android.car.vms.VmsLayer> mLayers\nprivate @android.annotation.NonNull java.util.Set<android.car.vms.VmsAssociatedLayer> mAssociatedLayers\nprivate  void onConstructed()\nprivate  void parcelLayers(android.os.Parcel,int)\nprivate @java.lang.SuppressWarnings(\"unchecked\") java.util.Set<android.car.vms.VmsLayer> unparcelLayers(android.os.Parcel)\nprivate  void parcelAssociatedLayers(android.os.Parcel,int)\nprivate @java.lang.SuppressWarnings(\"unchecked\") java.util.Set<android.car.vms.VmsAssociatedLayer> unparcelAssociatedLayers(android.os.Parcel)\nclass VmsSubscriptionState extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=true, genEqualsHashCode=true, genToString=true)")
249     @Deprecated
__metadata()250     private void __metadata() {}
251 
252 
253     //@formatter:on
254     // End of generated code
255 
256 }
257