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.ArrayList; 24 import java.util.Collections; 25 import java.util.HashSet; 26 import java.util.List; 27 import java.util.Objects; 28 import java.util.Set; 29 30 /** 31 * The state of dependencies for a single publisher. 32 * 33 * @hide 34 */ 35 @SystemApi 36 public final class VmsLayersOffering implements Parcelable { 37 38 private final Set<VmsLayerDependency> mDependencies; 39 40 private final int mPublisherId; 41 VmsLayersOffering(Set<VmsLayerDependency> dependencies, int publisherId)42 public VmsLayersOffering(Set<VmsLayerDependency> dependencies, int publisherId) { 43 mDependencies = Collections.unmodifiableSet(dependencies); 44 mPublisherId = publisherId; 45 } 46 47 /** 48 * Returns the dependencies. 49 */ getDependencies()50 public Set<VmsLayerDependency> getDependencies() { 51 return mDependencies; 52 } 53 getPublisherId()54 public int getPublisherId() { 55 return mPublisherId; 56 } 57 58 public static final Parcelable.Creator<VmsLayersOffering> CREATOR = new 59 Parcelable.Creator<VmsLayersOffering>() { 60 public VmsLayersOffering createFromParcel(Parcel in) { 61 return new VmsLayersOffering(in); 62 } 63 64 public VmsLayersOffering[] newArray(int size) { 65 return new VmsLayersOffering[size]; 66 } 67 }; 68 69 @Override toString()70 public String toString() { 71 return "VmsLayersOffering{ Publisher: " + 72 mPublisherId + 73 " Dependencies: " + 74 mDependencies + 75 "}"; 76 } 77 78 @Override writeToParcel(Parcel out, int flags)79 public void writeToParcel(Parcel out, int flags) { 80 81 out.writeParcelableList(new ArrayList(mDependencies), flags); 82 out.writeInt(mPublisherId); 83 } 84 85 @Override equals(Object o)86 public boolean equals(Object o) { 87 if (!(o instanceof VmsLayersOffering)) { 88 return false; 89 } 90 VmsLayersOffering p = (VmsLayersOffering) o; 91 return Objects.equals(p.mPublisherId, mPublisherId) && p.mDependencies.equals(mDependencies); 92 } 93 94 @Override hashCode()95 public int hashCode() { 96 return Objects.hash(mPublisherId, mDependencies); 97 } 98 99 @Override describeContents()100 public int describeContents() { 101 return 0; 102 } 103 VmsLayersOffering(Parcel in)104 private VmsLayersOffering(Parcel in) { 105 List<VmsLayerDependency> dependencies = new ArrayList<>(); 106 in.readParcelableList(dependencies, VmsLayerDependency.class.getClassLoader()); 107 mDependencies = Collections.unmodifiableSet(new HashSet<>(dependencies)); 108 mPublisherId = in.readInt(); 109 } 110 }