1 /* |
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 package jdk.tools.jlink.plugin; |
|
26 |
|
27 import java.nio.ByteOrder; |
|
28 import java.util.Map; |
|
29 import java.util.Optional; |
|
30 import java.util.function.Function; |
|
31 import java.util.stream.Stream; |
|
32 |
|
33 /** |
|
34 * Pool of module data. |
|
35 */ |
|
36 public interface ModulePool { |
|
37 /** |
|
38 * Is this a read-only ModulePool? |
|
39 * |
|
40 * @return true if this is a read-only configuration. |
|
41 */ |
|
42 public boolean isReadOnly(); |
|
43 |
|
44 /** |
|
45 * Add a ModuleEntry. |
|
46 * |
|
47 * @param data The ModuleEntry to add. |
|
48 */ |
|
49 public void add(ModuleEntry data); |
|
50 /** |
|
51 * Retrieves the module for the provided name. |
|
52 * |
|
53 * @param name The module name |
|
54 * @return the module of matching name, if found |
|
55 */ |
|
56 public Optional<LinkModule> findModule(String name); |
|
57 |
|
58 /** |
|
59 * The stream of modules contained in this ModulePool. |
|
60 * |
|
61 * @return The stream of modules. |
|
62 */ |
|
63 public Stream<? extends LinkModule> modules(); |
|
64 |
|
65 /** |
|
66 * Return the number of LinkModule count in this ModulePool. |
|
67 * |
|
68 * @return the module count. |
|
69 */ |
|
70 public int getModuleCount(); |
|
71 |
|
72 /** |
|
73 * Get all ModuleEntry contained in this ModulePool instance. |
|
74 * |
|
75 * @return The stream of LinkModuleEntries. |
|
76 */ |
|
77 public Stream<? extends ModuleEntry> entries(); |
|
78 |
|
79 /** |
|
80 * Return the number of ModuleEntry count in this ModulePool. |
|
81 * |
|
82 * @return the entry count. |
|
83 */ |
|
84 public int getEntryCount(); |
|
85 |
|
86 /** |
|
87 * Get the ModuleEntry for the passed path. |
|
88 * |
|
89 * @param path A data path |
|
90 * @return A ModuleEntry instance or null if the data is not found |
|
91 */ |
|
92 public Optional<ModuleEntry> findEntry(String path); |
|
93 |
|
94 /** |
|
95 * Get the ModuleEntry for the passed path restricted to supplied context. |
|
96 * |
|
97 * @param path A data path |
|
98 * @param context A context of the search |
|
99 * @return A ModuleEntry instance or null if the data is not found |
|
100 */ |
|
101 public Optional<ModuleEntry> findEntryInContext(String path, ModuleEntry context); |
|
102 |
|
103 /** |
|
104 * Check if the ModulePool contains the given ModuleEntry. |
|
105 * |
|
106 * @param data The module data to check existence for. |
|
107 * @return The module data or null if not found. |
|
108 */ |
|
109 public boolean contains(ModuleEntry data); |
|
110 |
|
111 /** |
|
112 * Check if the ModulePool contains some content at all. |
|
113 * |
|
114 * @return True, no content, false otherwise. |
|
115 */ |
|
116 public boolean isEmpty(); |
|
117 |
|
118 /** |
|
119 * Visit each ModuleEntry in this ModulePool to transform it and copy |
|
120 * the transformed ModuleEntry to the output ModulePool. |
|
121 * |
|
122 * @param transform The function called for each ModuleEntry found in the |
|
123 * ModulePool. The transform function should return a ModuleEntry |
|
124 * instance which will be added to the output or it should return null if |
|
125 * the passed ModuleEntry is to be ignored for the output. |
|
126 * |
|
127 * @param output The ModulePool to be filled with Visitor returned |
|
128 * ModuleEntry. |
|
129 */ |
|
130 public void transformAndCopy(Function<ModuleEntry, ModuleEntry> transform, ModulePool output); |
|
131 |
|
132 /** |
|
133 * The ByteOrder currently in use when generating the jimage file. |
|
134 * |
|
135 * @return The ByteOrder. |
|
136 */ |
|
137 public ByteOrder getByteOrder(); |
|
138 |
|
139 /** |
|
140 * Release properties such as OS, CPU name, version etc. |
|
141 * |
|
142 * @return the release properties |
|
143 */ |
|
144 public Map<String, String> getReleaseProperties(); |
|
145 } |
|