• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.SystemApi;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import java.util.Objects;
24 
25 /**
26  * A VMS Layer which can be subscribed to by VMS clients.
27  *
28  * @hide
29  */
30 @SystemApi
31 public final class VmsLayer implements Parcelable {
32 
33     // The layer Type.
34     private int mType;
35 
36     // The layer Subtype.
37     private int mSubtype;
38 
39     // The layer version.
40     private int mVersion;
41 
VmsLayer(int type, int subtype, int version)42     public VmsLayer(int type, int subtype, int version) {
43         mType = type;
44         mSubtype = subtype;
45         mVersion = version;
46     }
47 
getType()48     public int getType() {
49         return mType;
50     }
51 
getSubtype()52     public int getSubtype() {
53         return mSubtype;
54     }
55 
getVersion()56     public int getVersion() {
57         return mVersion;
58     }
59 
60     /**
61      * Checks the two objects for equality by comparing their IDs and Versions.
62      *
63      * @param o the {@link VmsLayer} to which this one is to be checked for equality
64      * @return true if the underlying objects of the VmsLayer are both considered equal
65      */
66     @Override
equals(Object o)67     public boolean equals(Object o) {
68         if (!(o instanceof VmsLayer)) {
69             return false;
70         }
71         VmsLayer p = (VmsLayer) o;
72         return Objects.equals(p.mType, mType) &&
73             Objects.equals(p.mSubtype, mSubtype) &&
74             Objects.equals(p.mVersion, mVersion);
75     }
76 
77     /**
78      * Compute a hash code similarly tp {@link android.util.Pair}
79      *
80      * @return a hashcode of the Pair
81      */
82     @Override
hashCode()83     public int hashCode() {
84         return Objects.hash(mType, mSubtype, mVersion);
85     }
86 
87     @Override
toString()88     public String toString() {
89         return "VmsLayer{ Type: " + mType + ", Sub type: " + mSubtype + ", Version: " + mVersion + "}";
90     }
91 
92 
93     // Parcelable related methods.
94     public static final Parcelable.Creator<VmsLayer> CREATOR = new
95             Parcelable.Creator<VmsLayer>() {
96                 public VmsLayer createFromParcel(Parcel in) {
97                     return new VmsLayer(in);
98                 }
99 
100                 public VmsLayer[] newArray(int size) {
101                     return new VmsLayer[size];
102                 }
103             };
104 
105     @Override
writeToParcel(Parcel out, int flags)106     public void writeToParcel(Parcel out, int flags) {
107         out.writeInt(mType);
108         out.writeInt(mSubtype);
109         out.writeInt(mVersion);
110     }
111 
112     @Override
describeContents()113     public int describeContents() {
114         return 0;
115     }
116 
VmsLayer(Parcel in)117     private VmsLayer(Parcel in) {
118         readFromParcel(in);
119     }
120 
readFromParcel(Parcel in)121     private void readFromParcel(Parcel in) {
122         mType = in.readInt();
123         mSubtype = in.readInt();
124         mVersion = in.readInt();
125     }
126 }