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 {
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(Object other)23     public int compareTo(Object other) {
24         AppVpnInfo that = (AppVpnInfo) other;
25 
26         int result = packageName.compareTo(that.packageName);
27         if (result == 0) {
28             result = that.userId - userId;
29         }
30         return result;
31     }
32 
33     @Override
equals(Object other)34     public boolean equals(Object other) {
35         if (other instanceof AppVpnInfo) {
36             AppVpnInfo that = (AppVpnInfo) other;
37             return userId == that.userId && Objects.equals(packageName, that.packageName);
38         }
39         return false;
40     }
41 
42     @Override
hashCode()43     public int hashCode() {
44         return Objects.hash(packageName, userId);
45     }
46 }
47