28 import java.util.ArrayList; |
28 import java.util.ArrayList; |
29 import java.util.Comparator; |
29 import java.util.Comparator; |
30 import java.util.List; |
30 import java.util.List; |
31 import java.util.function.Function; |
31 import java.util.function.Function; |
32 import jdk.tools.jlink.plugin.Plugin; |
32 import jdk.tools.jlink.plugin.Plugin; |
33 import jdk.tools.jlink.plugin.Plugin.PluginType; |
|
34 |
33 |
35 public class Utils { |
34 public class Utils { |
36 |
35 |
37 private Utils() {} |
36 private Utils() {} |
38 |
37 |
48 } |
47 } |
49 } |
48 } |
50 return arguments; |
49 return arguments; |
51 }; |
50 }; |
52 |
51 |
53 public static boolean isPostProcessor(Plugin.CATEGORY category) { |
52 public static boolean isPostProcessor(Plugin.Category category) { |
54 return category.equals(Plugin.CATEGORY.VERIFIER) |
53 return category.equals(Plugin.Category.VERIFIER) |
55 || category.equals(Plugin.CATEGORY.PROCESSOR) |
54 || category.equals(Plugin.Category.PROCESSOR) |
56 || category.equals(Plugin.CATEGORY.PACKAGER); |
55 || category.equals(Plugin.Category.PACKAGER); |
57 } |
56 } |
58 |
57 |
59 public static boolean isPreProcessor(Plugin.CATEGORY category) { |
58 public static boolean isPreProcessor(Plugin.Category category) { |
60 return category.equals(Plugin.CATEGORY.COMPRESSOR) |
59 return category.equals(Plugin.Category.COMPRESSOR) |
61 || category.equals(Plugin.CATEGORY.FILTER) |
60 || category.equals(Plugin.Category.FILTER) |
62 || category.equals(Plugin.CATEGORY.MODULEINFO_TRANSFORMER) |
61 || category.equals(Plugin.Category.MODULEINFO_TRANSFORMER) |
63 || category.equals(Plugin.CATEGORY.SORTER) |
62 || category.equals(Plugin.Category.SORTER) |
64 || category.equals(Plugin.CATEGORY.TRANSFORMER); |
63 || category.equals(Plugin.Category.TRANSFORMER) |
|
64 || category.equals(Plugin.Category.METAINFO_ADDER); |
65 } |
65 } |
66 |
66 |
67 public static boolean isPostProcessor(Plugin prov) { |
67 public static boolean isPostProcessor(Plugin prov) { |
68 if (prov.getType() != null) { |
68 if (prov.getType() != null) { |
69 for (PluginType pt : prov.getType()) { |
69 for (Plugin.Category pt : prov.getType()) { |
70 if (pt instanceof Plugin.CATEGORY) { |
70 if (pt instanceof Plugin.Category) { |
71 return isPostProcessor((Plugin.CATEGORY) pt); |
71 return isPostProcessor(pt); |
72 } |
72 } |
73 } |
73 } |
74 } |
74 } |
75 return false; |
75 return false; |
76 } |
76 } |
77 |
77 |
78 public static boolean isPreProcessor(Plugin prov) { |
78 public static boolean isPreProcessor(Plugin prov) { |
79 if (prov.getType() != null) { |
79 if (prov.getType() != null) { |
80 for (PluginType pt : prov.getType()) { |
80 for (Plugin.Category pt : prov.getType()) { |
81 if (pt instanceof Plugin.CATEGORY) { |
81 if (pt instanceof Plugin.Category) { |
82 return isPreProcessor((Plugin.CATEGORY) pt); |
82 return isPreProcessor(pt); |
83 } |
83 } |
84 } |
84 } |
85 } |
85 } |
86 return false; |
86 return false; |
87 } |
87 } |
88 |
88 |
89 public static Plugin.CATEGORY getCategory(Plugin provider) { |
89 public static Plugin.Category getCategory(Plugin provider) { |
90 if (provider.getType() != null) { |
90 if (provider.getType() != null) { |
91 for (Plugin.PluginType t : provider.getType()) { |
91 for (Plugin.Category t : provider.getType()) { |
92 if (t instanceof Plugin.CATEGORY) { |
92 if (t instanceof Plugin.Category) { |
93 return (Plugin.CATEGORY) t; |
93 return t; |
94 } |
94 } |
95 } |
95 } |
96 } |
96 } |
97 return null; |
97 return null; |
98 } |
98 } |
138 } |
138 } |
139 return res; |
139 return res; |
140 } |
140 } |
141 |
141 |
142 public static boolean isFunctional(Plugin prov) { |
142 public static boolean isFunctional(Plugin prov) { |
143 return prov.getState().contains(Plugin.STATE.FUNCTIONAL); |
143 return prov.getState().contains(Plugin.State.FUNCTIONAL); |
144 } |
144 } |
145 |
145 |
146 public static boolean isAutoEnabled(Plugin prov) { |
146 public static boolean isAutoEnabled(Plugin prov) { |
147 return prov.getState().contains(Plugin.STATE.AUTO_ENABLED); |
147 return prov.getState().contains(Plugin.State.AUTO_ENABLED); |
148 } |
148 } |
149 |
149 |
150 public static boolean isDisabled(Plugin prov) { |
150 public static boolean isDisabled(Plugin prov) { |
151 return prov.getState().contains(Plugin.STATE.DISABLED); |
151 return prov.getState().contains(Plugin.State.DISABLED); |
152 } |
152 } |
153 |
153 |
154 // is this a builtin (jdk.jlink) plugin? |
154 // is this a builtin (jdk.jlink) plugin? |
155 public static boolean isBuiltin(Plugin prov) { |
155 public static boolean isBuiltin(Plugin prov) { |
156 return THIS_MODULE.equals(prov.getClass().getModule()); |
156 return THIS_MODULE.equals(prov.getClass().getModule()); |