1 /*
2  * Copyright (C) 2022 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.libraries.pcc.chronicle.analysis
18 
19 import com.android.libraries.pcc.chronicle.api.DataTypeDescriptor
20 import com.android.libraries.pcc.chronicle.api.ManagementStrategy
21 import com.android.libraries.pcc.chronicle.api.policy.Policy
22 
23 /**
24  * Data structure which manages the collection of known [Policies][Policy] and provides utilities to
25  * understand the context it implies.
26  */
27 interface PolicySet {
28   /** Finds and returns (if found) the [Policy] in this [PolicySet] with the given [policyName]. */
findByNamenull29   fun findByName(policyName: String): Policy?
30 
31   /** Returns whether or not the given [Policy] is known to the [PolicySet] already. */
32   operator fun contains(policy: Policy): Boolean
33 
34   /**
35    * Returns the set of [ManagementStrategies][ManagementStrategy] of storage that is specified in
36    * all [policies][Policy] mentioning the given [dataTypeDescriptor].
37    */
38   fun findManagementStrategies(dataTypeDescriptor: DataTypeDescriptor): Set<ManagementStrategy>
39 
40   /** Returns the policies as a set. */
41   fun toSet(): Set<Policy>
42 }
43