Debian Codegraph @

apex/jobscheduler/service/java/com/android/server/job/controllers/Package.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 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 com.android.server.job.controllers;
18
19 import java.util.Objects;
20
21 /** Wrapper class to represent a userId-pkgName combo. */
22 final class Package {
23 public final String packageName;
24 public final int userId;
25
26 Package(int userId, String packageName) {
27 this.userId = userId;
28 this.packageName = packageName;
29 }
30
31 @Override
32 public String toString() {
33 return packageToString(userId, packageName);
34 }
35
36 @Override
37 public boolean equals(Object obj) {
38 if (this == obj) {
39 return true;
40 }
41 if (!(obj instanceof Package)) {
42 return false;
43 }
44 Package other = (Package) obj;
45 return userId == other.userId && Objects.equals(packageName, other.packageName);
46 }
47
48 @Override
49 public int hashCode() {
50 return packageName.hashCode() + userId;
51 }
52
53 /**
54 * Standardize the output of userId-packageName combo.
55 */
56 static String packageToString(int userId, String packageName) {
57 return "<" + userId + ">" + packageName;
58 }
59 }