1 package com.android.settings.vpn2; 2 3 import android.annotation.NonNull; 4 5 import com.android.internal.util.Preconditions; 6 7 import java.util.Objects; 8 9 /** 10 * Holds packageName:userId pairs without any heavyweight fields. 11 * {@see ApplicationInfo} 12 */ 13 class AppVpnInfo implements Comparable<AppVpnInfo> { 14 public final int userId; 15 public final String packageName; 16 AppVpnInfo(int userId, @NonNull String packageName)17 public AppVpnInfo(int userId, @NonNull String packageName) { 18 this.userId = userId; 19 this.packageName = Preconditions.checkNotNull(packageName); 20 } 21 22 @Override compareTo(AppVpnInfo other)23 public int compareTo(AppVpnInfo other) { 24 int result = packageName.compareTo(other.packageName); 25 if (result == 0) { 26 result = other.userId - userId; 27 } 28 return result; 29 } 30 31 @Override equals(Object other)32 public boolean equals(Object other) { 33 if (other instanceof AppVpnInfo) { 34 AppVpnInfo that = (AppVpnInfo) other; 35 return userId == that.userId && Objects.equals(packageName, that.packageName); 36 } 37 return false; 38 } 39 40 @Override hashCode()41 public int hashCode() { 42 return Objects.hash(packageName, userId); 43 } 44 } 45