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