|
3 | 3 | import static java.util.Objects.requireNonNull; |
4 | 4 |
|
5 | 5 | import java.util.List; |
6 | | -import java.util.Optional; |
7 | 6 | import java.util.Set; |
8 | 7 | import java.util.stream.Stream; |
9 | 8 |
|
10 | | -import org.jspecify.annotations.Nullable; |
11 | | - |
12 | 9 | import app.packed.application.ApplicationMirror; |
13 | 10 | import app.packed.assembly.AssemblyMirror; |
14 | 11 | import app.packed.bean.BeanMirror; |
|
19 | 16 | import app.packed.component.ComponentRealm; |
20 | 17 | import app.packed.extension.BaseExtension; |
21 | 18 | import app.packed.extension.Extension; |
22 | | -import app.packed.extension.ExtensionMirror; |
23 | 19 | import app.packed.namespace.NamespaceMirror; |
24 | 20 | import app.packed.operation.OperationMirror; |
25 | 21 | import app.packed.util.TreeView; |
26 | 22 | import internal.app.packed.bean.introspection.IntrospectorOnAutoService; |
27 | | -import internal.app.packed.container.ContainerSetup; |
28 | | -import internal.app.packed.extension.ExtensionClassModel; |
29 | | -import internal.app.packed.extension.ExtensionSetup; |
30 | 23 | import internal.app.packed.extension.base.BaseExtensionBeanIntrospector; |
31 | 24 | import internal.app.packed.util.PackedTreeView; |
32 | | -import internal.app.packed.util.types.ClassUtil; |
33 | | -import internal.app.packed.util.types.TypeVariableExtractor; |
34 | 25 |
|
35 | 26 | /** |
36 | 27 | * A mirror of a container. |
|
43 | 34 | @AutoServiceInheritable(introspector = ContainerMirrorBeanIntrospector.class) |
44 | 35 | public non-sealed class ContainerMirror implements ComponentMirror, ContainerBuildLocal.Accessor { |
45 | 36 |
|
46 | | - /** Extract the (extension class) type variable from ExtensionMirror. */ |
47 | | - private final static ClassValue<Class<? extends Extension<?>>> EXTENSION_TYPES = new ClassValue<>() { |
48 | | - |
49 | | - /** A type variable extractor. */ |
50 | | - private static final TypeVariableExtractor EXTRACTOR = TypeVariableExtractor.of(ExtensionMirror.class); |
51 | | - |
52 | | - /** {@inheritDoc} */ |
53 | | - @Override |
54 | | - protected Class<? extends Extension<?>> computeValue(Class<?> type) { |
55 | | - return ExtensionClassModel.extractE(EXTRACTOR, type); |
56 | | - } |
57 | | - }; |
58 | | - |
59 | 37 | /** The container we are mirroring. */ |
60 | 38 | final ContainerHandle<?> handle; |
61 | 39 |
|
@@ -132,21 +110,6 @@ public final Set<Class<? extends Extension<?>>> extensionTypes() { |
132 | 110 | return handle.container.extensionTypes(); |
133 | 111 | } |
134 | 112 |
|
135 | | - /** |
136 | | - * <p> |
137 | | - * If you know for certain that extension is used in the container you can use {@link #use(Class)} instead. |
138 | | - * |
139 | | - * @param <T> |
140 | | - * the type of mirror |
141 | | - * @param mirrorType |
142 | | - * the mirror type |
143 | | - * @return a mirror of the specified type, or empty if the extension the mirror represents is not used in the container |
144 | | - */ |
145 | | - public final <T extends ExtensionMirror<?>> Optional<T> findExtension(Class<T> mirrorType) { |
146 | | - ClassUtil.checkProperSubclass(ExtensionMirror.class, mirrorType, "mirrorType"); |
147 | | - return Optional.ofNullable(newMirrorOrNull(handle.container, mirrorType)); |
148 | | - } |
149 | | - |
150 | 113 | /** {@inheritDoc} */ |
151 | 114 | @Override |
152 | 115 | public final int hashCode() { |
@@ -208,32 +171,6 @@ public final List<WireletMirror> wirelets() { |
208 | 171 | throw new UnsupportedOperationException(); |
209 | 172 | } |
210 | 173 |
|
211 | | - /** |
212 | | - * Creates a new mirror if an. Otherwise returns {@code null} |
213 | | - * |
214 | | - * @param container |
215 | | - * the container to test for presence extension may be present |
216 | | - * @param mirrorClass |
217 | | - * the type of mirror to return |
218 | | - * @return a mirror of the specified type or null if no extension of the matching type was used in the container |
219 | | - */ |
220 | | - @Nullable |
221 | | - static <T extends ExtensionMirror<?>> T newMirrorOrNull(ContainerSetup container, Class<T> mirrorClass) { |
222 | | - // Extract <E> from ExtensionMirror<E extends Extension> |
223 | | - Class<? extends Extension<?>> extensionType = EXTENSION_TYPES.get(mirrorClass); |
224 | | - |
225 | | - ExtensionMirror<?> mirror = null; |
226 | | - |
227 | | - // See if the extension is in use. |
228 | | - ExtensionSetup extension = container.extensions.get(extensionType); |
229 | | - if (extension != null) { |
230 | | - // Call Extension#newExtensionMirror |
231 | | - mirror = extension.newExtensionMirror(mirrorClass); |
232 | | - requireNonNull(mirror); |
233 | | - // Should take an ExtensionHandle |
234 | | - } |
235 | | - return mirrorClass.cast(mirror); |
236 | | - } |
237 | 174 | } |
238 | 175 |
|
239 | 176 | final class ContainerMirrorBeanIntrospector extends BaseExtensionBeanIntrospector { |
|
0 commit comments