1 /* 2 * Copyright (C) 2023 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.app.admin; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.ComponentName; 22 import android.os.Parcel; 23 24 import java.util.Objects; 25 26 /** 27 * @hide 28 */ 29 public final class ComponentNamePolicyValue extends PolicyValue<ComponentName> { 30 ComponentNamePolicyValue(@onNull ComponentName value)31 public ComponentNamePolicyValue(@NonNull ComponentName value) { 32 super(value); 33 } 34 ComponentNamePolicyValue(Parcel source)35 private ComponentNamePolicyValue(Parcel source) { 36 this((ComponentName) source.readParcelable(ComponentName.class.getClassLoader())); 37 } 38 39 @Override equals(@ullable Object o)40 public boolean equals(@Nullable Object o) { 41 if (this == o) return true; 42 if (o == null || getClass() != o.getClass()) return false; 43 ComponentNamePolicyValue other = (ComponentNamePolicyValue) o; 44 return Objects.equals(getValue(), other.getValue()); 45 } 46 47 @Override hashCode()48 public int hashCode() { 49 return Objects.hash(getValue()); 50 } 51 52 @Override toString()53 public String toString() { 54 return "ComponentNamePolicyValue { mValue= " + getValue() + " }"; 55 } 56 57 @Override describeContents()58 public int describeContents() { 59 return 0; 60 } 61 62 @Override writeToParcel(@onNull Parcel dest, int flags)63 public void writeToParcel(@NonNull Parcel dest, int flags) { 64 dest.writeParcelable(getValue(), flags); 65 } 66 67 @NonNull 68 public static final Creator<ComponentNamePolicyValue> CREATOR = 69 new Creator<ComponentNamePolicyValue>() { 70 @Override 71 public ComponentNamePolicyValue createFromParcel(Parcel source) { 72 return new ComponentNamePolicyValue(source); 73 } 74 75 @Override 76 public ComponentNamePolicyValue[] newArray(int size) { 77 return new ComponentNamePolicyValue[size]; 78 } 79 }; 80 } 81