1 /* 2 * Copyright (C) 2018 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.permissioncontroller.role.model; 18 19 import androidx.annotation.NonNull; 20 21 import java.util.List; 22 import java.util.Objects; 23 24 /** 25 * A set of permissions with a name to be granted by a {@link Role}. 26 */ 27 public class PermissionSet { 28 29 /** 30 * The name of this permission set. Must be unique. 31 */ 32 @NonNull 33 private final String mName; 34 35 /** 36 * The permissions of this permission set. 37 */ 38 @NonNull 39 private final List<String> mPermissions; 40 PermissionSet(@onNull String name, @NonNull List<String> permissions)41 public PermissionSet(@NonNull String name, @NonNull List<String> permissions) { 42 mName = name; 43 mPermissions = permissions; 44 } 45 46 @NonNull getName()47 public String getName() { 48 return mName; 49 } 50 51 @NonNull getPermissions()52 public List<String> getPermissions() { 53 return mPermissions; 54 } 55 56 @Override toString()57 public String toString() { 58 return "PermissionSet{" 59 + "mName='" + mName + '\'' 60 + ", mPermissions=" + mPermissions 61 + '}'; 62 } 63 64 @Override equals(Object object)65 public boolean equals(Object object) { 66 if (this == object) { 67 return true; 68 } 69 if (object == null || getClass() != object.getClass()) { 70 return false; 71 } 72 PermissionSet that = (PermissionSet) object; 73 return Objects.equals(mName, that.mName) 74 && Objects.equals(mPermissions, that.mPermissions); 75 } 76 77 @Override hashCode()78 public int hashCode() { 79 return Objects.hash(mName, mPermissions); 80 } 81 } 82