blob: b921230fb066aad9f7d9c7182f0051d5e11facd0 [file] [log] [blame]
asafroe102dc62017-02-23 14:54:11 -08001/*
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
Antonio Cortes0bd67c32017-03-13 08:02:40 -070017package android.car.vms;
asafroe102dc62017-02-23 14:54:11 -080018
Asaf Rosenfeld39e4f032017-09-16 11:33:50 -070019import android.annotation.SystemApi;
Antonio Cortes0bd67c32017-03-13 08:02:40 -070020import android.os.Parcel;
21import android.os.Parcelable;
asafroe102dc62017-02-23 14:54:11 -080022
23import java.util.Objects;
24
25/**
26 * A VMS Layer which can be subscribed to by VMS clients.
Antonio Cortes0bd67c32017-03-13 08:02:40 -070027 *
28 * @hide
asafroe102dc62017-02-23 14:54:11 -080029 */
Asaf Rosenfeld39e4f032017-09-16 11:33:50 -070030@SystemApi
Antonio Cortes0bd67c32017-03-13 08:02:40 -070031public final class VmsLayer implements Parcelable {
asafroe102dc62017-02-23 14:54:11 -080032
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -070033 // The layer Type.
34 private int mType;
35
36 // The layer Subtype.
37 private int mSubtype;
asafroe102dc62017-02-23 14:54:11 -080038
39 // The layer version.
Antonio Cortes0bd67c32017-03-13 08:02:40 -070040 private int mVersion;
asafroe102dc62017-02-23 14:54:11 -080041
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -070042 public VmsLayer(int type, int subtype, int version) {
43 mType = type;
44 mSubtype = subtype;
asafroe102dc62017-02-23 14:54:11 -080045 mVersion = version;
46 }
47
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -070048 public int getType() {
49 return mType;
50 }
51
52 public int getSubtype() {
53 return mSubtype;
asafroe102dc62017-02-23 14:54:11 -080054 }
55
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
67 public boolean equals(Object o) {
68 if (!(o instanceof VmsLayer)) {
69 return false;
70 }
71 VmsLayer p = (VmsLayer) o;
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -070072 return Objects.equals(p.mType, mType) &&
73 Objects.equals(p.mSubtype, mSubtype) &&
74 Objects.equals(p.mVersion, mVersion);
asafroe102dc62017-02-23 14:54:11 -080075 }
76
77 /**
78 * Compute a hash code similarly tp {@link android.util.Pair}
79 *
80 * @return a hashcode of the Pair
81 */
82 @Override
83 public int hashCode() {
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -070084 return Objects.hash(mType, mSubtype, mVersion);
asafroe102dc62017-02-23 14:54:11 -080085 }
86
87 @Override
88 public String toString() {
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -070089 return "VmsLayer{ Type: " + mType + ", Sub type: " + mSubtype + ", Version: " + mVersion + "}";
asafroe102dc62017-02-23 14:54:11 -080090 }
Antonio Cortes0bd67c32017-03-13 08:02:40 -070091
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
106 public void writeToParcel(Parcel out, int flags) {
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -0700107 out.writeInt(mType);
108 out.writeInt(mSubtype);
Asaf Rosenfeld58e180b2017-07-27 21:06:30 -0700109 out.writeInt(mVersion);
Antonio Cortes0bd67c32017-03-13 08:02:40 -0700110 }
111
112 @Override
113 public int describeContents() {
114 return 0;
115 }
116
117 private VmsLayer(Parcel in) {
118 readFromParcel(in);
119 }
120
121 private void readFromParcel(Parcel in) {
Asaf Rosenfeld2e45d812017-08-31 23:51:12 -0700122 mType = in.readInt();
123 mSubtype = in.readInt();
Asaf Rosenfeld58e180b2017-07-27 21:06:30 -0700124 mVersion = in.readInt();
Antonio Cortes0bd67c32017-03-13 08:02:40 -0700125 }
asafroe102dc62017-02-23 14:54:11 -0800126}