Coverage Summary for Class: MultiplePermissionState (dev.shreyaspatil.permissionFlow)

Class Method, % Branch, % Line, % Instruction, %
MultiplePermissionState 100% (1/1) 100% (4/4) 100% (50/50)
MultiplePermissionState$allGranted$2 100% (1/1) 100% (1/1) 100% (9/9)
MultiplePermissionState$deniedPermissions$2 100% (1/1) 100% (2/2) 100% (1/1) 100% (20/20)
MultiplePermissionState$grantedPermissions$2 100% (1/1) 100% (1/1) 100% (16/16)
Total 100% (4/4) 100% (2/2) 100% (7/7) 100% (95/95)


1 /** 2  * Copyright 2022 Shreyas Patil 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 package dev.shreyaspatil.permissionFlow 17  18 /** 19  * State model of a permission 20  * 21  * @property permission Name of a permission 22  * @property isGranted State of a permission whether it's granted or not 23  */ 24 data class PermissionState(val permission: String, val isGranted: Boolean) 25  26 /** 27  * State model for multiple permissions 28  * 29  * @property permissions List of state of multiple permissions 30  */ 31 data class MultiplePermissionState(val permissions: List<PermissionState>) { 32  33  /** 34  * Returns true if all permissions are granted by user 35  */ 36  val allGranted by lazy { permissions.all { it.isGranted } } 37  38  /** 39  * List of permissions which are granted by user 40  */ 41  val grantedPermissions by lazy { permissions.filter { it.isGranted }.map { it.permission } } 42  43  /** 44  * List of permissions which are denied / not granted by user 45  */ 46  val deniedPermissions by lazy { permissions.filter { !it.isGranted }.map { it.permission } } 47 }