1 /*
2  * Copyright (C) 2021 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.csuite.core;
18 
19 import com.android.tradefed.config.IConfiguration;
20 
21 import com.google.common.annotations.VisibleForTesting;
22 import com.google.errorprone.annotations.MustBeClosed;
23 
24 import java.io.IOException;
25 import java.util.stream.Stream;
26 
27 /** An interface for providing module configuration contents. */
28 public interface ModuleInfoProvider {
29     @VisibleForTesting String MODULE_INFO_PROVIDER_OBJECT_TYPE = "MODULE_INFO_PROVIDER";
30 
31     final class ModuleInfo {
32         private final String mName;
33         private final String mContent;
34 
ModuleInfo(String name, String content)35         public ModuleInfo(String name, String content) {
36             mName = name;
37             mContent = content;
38         }
39 
getName()40         public String getName() {
41             return mName;
42         }
43 
getContent()44         public String getContent() {
45             return mContent;
46         }
47     }
48 
49     /**
50      * Returns a stream of module configuration contents.
51      *
52      * @param configuration TradeFed suite configuration.
53      * @return A stream of ModuleInfo objects.
54      * @throws IOException if any IO exception occurs.
55      */
56     @MustBeClosed
get(IConfiguration configuration)57     Stream<ModuleInfo> get(IConfiguration configuration) throws IOException;
58 }
59