1 /*
2  * Copyright (C) 2020 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 package com.android.tradefed.config.yaml;
17 
18 import com.android.tradefed.config.ConfigurationDef;
19 
20 import java.util.LinkedHashSet;
21 import java.util.Set;
22 
23 /**
24  * Interface for loading the default objects that should be part of our YAML configuration. This
25  * allows to customize the YAML configuration with any objects we need based on the context.
26  */
27 public interface IDefaultObjectLoader {
28 
29     /** Allows to add any default objects as necessary. */
addDefaultObjects(LoaderConfiguration loaderConfiguration)30     public void addDefaultObjects(LoaderConfiguration loaderConfiguration);
31 
32     /** The loading configuration object to pass information to the loader. */
33     public class LoaderConfiguration {
34 
35         private ConfigurationDef mConfigDef;
36         private boolean mCreatedAsModule = false;
37         private Set<String> mDependencies = new LinkedHashSet<>();
38 
setConfigurationDef(ConfigurationDef configDef)39         public LoaderConfiguration setConfigurationDef(ConfigurationDef configDef) {
40             mConfigDef = configDef;
41             return this;
42         }
43 
addDependencies(Set<String> dependencies)44         public LoaderConfiguration addDependencies(Set<String> dependencies) {
45             mDependencies.addAll(dependencies);
46             return this;
47         }
48 
addDependency(String dependency)49         public LoaderConfiguration addDependency(String dependency) {
50             mDependencies.add(dependency);
51             return this;
52         }
53 
setCreatedAsModule(boolean createdAsModule)54         public LoaderConfiguration setCreatedAsModule(boolean createdAsModule) {
55             mCreatedAsModule = createdAsModule;
56             return this;
57         }
58 
getConfigDef()59         public ConfigurationDef getConfigDef() {
60             return mConfigDef;
61         }
62 
getDependencies()63         public Set<String> getDependencies() {
64             return mDependencies;
65         }
66 
createdAsModule()67         public boolean createdAsModule() {
68             return mCreatedAsModule;
69         }
70     }
71 }
72