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.safetycenter;
18 
19 import android.safetycenter.config.SafetySourcesGroup;
20 
21 import com.android.modules.utils.build.SdkLevel;
22 
23 /** Static utilities for working with {@link SafetySourcesGroup} objects. */
24 final class SafetySourcesGroups {
25 
26     /**
27      * Returns a builder with all fields of the original group copied other than {@link
28      * SafetySourcesGroup#getSafetySources()}.
29      */
copyToBuilderWithoutSources(SafetySourcesGroup group)30     static SafetySourcesGroup.Builder copyToBuilderWithoutSources(SafetySourcesGroup group) {
31         SafetySourcesGroup.Builder safetySourcesGroupBuilder =
32                 new SafetySourcesGroup.Builder()
33                         .setId(group.getId())
34                         .setTitleResId(group.getTitleResId())
35                         .setSummaryResId(group.getSummaryResId())
36                         .setStatelessIconType(group.getStatelessIconType());
37         if (SdkLevel.isAtLeastU()) {
38             safetySourcesGroupBuilder.setType(group.getType());
39         }
40         return safetySourcesGroupBuilder;
41     }
42 
SafetySourcesGroups()43     private SafetySourcesGroups() {}
44 }
45