Skip to content

Commit 3bf40ba

Browse files
committed
r
1 parent d87ef5a commit 3bf40ba

File tree

2 files changed

+66
-91
lines changed

2 files changed

+66
-91
lines changed

modules/packed/src/main/java/app/packed/container/ContainerTemplate.java

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -85,37 +85,35 @@ public sealed interface ContainerTemplate<H extends ContainerHandle<?>> permits
8585
// Carefull with Unmanaged on Managed
8686
ContainerTemplate<?> UNMANAGED = new PackedContainerTemplate<>(PackedContainerKind.UNMANAGED);
8787

88-
public interface Configurator {
89-
90-
/**
91-
* @param <T>
92-
* @param key
93-
* @param arg
94-
* @return
95-
* @see app.packed.component.guest.FromComponentGuest
96-
*/
97-
default <T> Configurator withCarrierProvideConstant(Class<T> key, T arg) {
98-
return withCarrierProvideConstant(Key.of(key), arg);
99-
}
88+
/**
89+
* @param <T>
90+
* @param key
91+
* @param arg
92+
* @return
93+
* @see app.packed.component.guest.FromComponentGuest
94+
*/
95+
default <T> ContainerTemplate<H> withCarrierProvideConstant(Class<T> key, T arg) {
96+
return withCarrierProvideConstant(Key.of(key), arg);
97+
}
10098

101-
/**
102-
* @see FromLifetimeChannel
103-
*/
104-
default <T> Configurator withCarrierProvideConstant(Key<T> key, T arg) {
105-
throw new UnsupportedOperationException();
106-
}
99+
/**
100+
* @see FromLifetimeChannel
101+
*/
102+
default <T> ContainerTemplate<H> withCarrierProvideConstant(Key<T> key, T arg) {
103+
throw new UnsupportedOperationException();
104+
}
107105

108-
/**
109-
* Add the specified tags to the application
110-
*
111-
* @param tags
112-
* the tags to add
113-
* @return this configurator
114-
*/
115-
Configurator withComponentTag(String... tags);
106+
/**
107+
* Add the specified tags to the application
108+
*
109+
* @param tags
110+
* the tags to add
111+
* @return this ContainerTemplate<H>
112+
*/
113+
ContainerTemplate<H> withComponentTag(String... tags);
116114

117115
// // Maybe put it on ContainerTemplate.
118-
// default Configurator configureRootContainerHandleFactory(Function<? super ContainerTemplate.Installer<?>, ? extends ContainerHandle<?>> handleFactory) {
116+
// default ContainerTemplate<H> configureRootContainerHandleFactory(Function<? super ContainerTemplate.Installer<?>, ? extends ContainerHandle<?>> handleFactory) {
119117
// throw new UnsupportedOperationException();
120118
// }
121119

@@ -135,24 +133,24 @@ default <T> Configurator withCarrierProvideConstant(Key<T> key, T arg) {
135133
// // HOW are we going to access this class????? Without a lookup object.
136134
// // Can't just initialize it'
137135
// @Deprecated // Guest bean
138-
// Configurator carrierType(Class<?> beanClass);
136+
// ContainerTemplate<H> carrierType(Class<?> beanClass);
139137

140-
// Har kun visibility for the installing extension
141-
Configurator withLifetimeOperationAddContext(int index, ContextTemplate template);
138+
// Har kun visibility for the installing extension
139+
ContainerTemplate<H> withLifetimeOperationAddContext(int index, ContextTemplate template);
142140

143-
default <T> Configurator withLocalSet(ContainerBuildLocal<T> containerLocal, T value) {
144-
throw new UnsupportedOperationException();
145-
}
141+
default <T> ContainerTemplate<H> withLocalSet(ContainerBuildLocal<T> containerLocal, T value) {
142+
throw new UnsupportedOperationException();
143+
}
146144

147-
Configurator withPack(OldContainerTemplateLink pack);
145+
ContainerTemplate<H> withPack(OldContainerTemplateLink pack);
148146

149-
default Configurator withPack(OldContainerTemplateLink... packs) {
150-
for (OldContainerTemplateLink p : packs) {
151-
withPack(p);
152-
}
153-
return this;
147+
default ContainerTemplate<H> withPack(OldContainerTemplateLink... packs) {
148+
for (OldContainerTemplateLink p : packs) {
149+
withPack(p);
154150
}
151+
return this;
155152
}
153+
156154
}
157155

158156
interface Zandbox {

modules/packed/src/main/java/internal/app/packed/container/PackedContainerTemplate.java

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.util.List;
1919
import java.util.Set;
20-
import java.util.function.Consumer;
2120
import java.util.function.Function;
2221

2322
import app.packed.component.guest.OldContainerTemplateLink;
@@ -70,73 +69,51 @@ public PackedContainerInstaller<?> newInstaller(Class<? extends Extension<?>> in
7069
return installer;
7170
}
7271

73-
74-
public static <H extends ContainerHandle<?>> PackedContainerTemplate<H> configure(PackedContainerTemplate<H> template,
75-
Consumer<? super Configurator> configure) {
76-
PackedContainerTemplateConfigurator<H> c = new PackedContainerTemplateConfigurator<>(template);
77-
configure.accept(c);
78-
return c.pbt;
79-
}
80-
81-
public final static class PackedContainerTemplateConfigurator<H extends ContainerHandle<?>> implements ContainerTemplate.Configurator {
82-
83-
public PackedContainerTemplate<H> pbt;
84-
85-
public PackedContainerTemplateConfigurator(PackedContainerTemplate<H> pbt) {
86-
this.pbt = pbt;
87-
}
88-
8972
// /** {@inheritDoc} */
9073
// @Override
9174
// public PackedContainerTemplateConfigurator carrierType(Class<?> guest) {
9275
// // I don't think we are going to do any checks here?
9376
// // Well not interface, annotation, abstract class, ...
9477
// // All lifetime operation will change...
95-
// this.pbt = new PackedContainerTemplate(pbt.kind, guest, pbt.links, pbt.resultType, pbt.componentTags, pbt.lifecycleKind);
78+
// this.pbt = new PackedContainerTemplate(kind, guest, links, resultType, componentTags, lifecycleKind);
9679
// return this;
9780
// }
9881

99-
// expects results. Maa ogsaa tage en Extension...
100-
public PackedContainerTemplateConfigurator<H> expectResult(Class<?> resultType) {
101-
this.pbt = new PackedContainerTemplate<>(pbt.kind, pbt.holderClass, pbt.links, resultType, pbt.componentTags, pbt.isManaged);
102-
return this;
103-
}
82+
// expects results. Maa ogsaa tage en Extension...
83+
public PackedContainerTemplate<H> expectResult(Class<?> resultType) {
84+
return new PackedContainerTemplate<>(kind, holderClass, links, resultType, componentTags, isManaged);
85+
}
10486

105-
/** {@inheritDoc} */
106-
@Override
107-
public PackedContainerTemplateConfigurator<H> withLifetimeOperationAddContext(int index, ContextTemplate template) {
108-
throw new UnsupportedOperationException();
109-
}
87+
/** {@inheritDoc} */
88+
@Override
89+
public PackedContainerTemplate<H> withLifetimeOperationAddContext(int index, ContextTemplate template) {
90+
throw new UnsupportedOperationException();
91+
}
11092

111-
public Wirelet wirelet() {
112-
return null;
113-
}
93+
public Wirelet wirelet() {
94+
return null;
95+
}
11496

115-
public PackedContainerTemplateConfigurator<H> withKind(PackedContainerKind kind) {
116-
this.pbt = new PackedContainerTemplate<>(kind, pbt.holderClass, pbt.links, pbt.resultType, pbt.componentTags, pbt.isManaged);
117-
return this;
118-
}
97+
public PackedContainerTemplate<H> withKind(PackedContainerKind kind) {
98+
return new PackedContainerTemplate<>(kind, holderClass, links, resultType, componentTags, isManaged);
99+
}
119100

120-
/** {@inheritDoc} */
121-
@Override
122-
public PackedContainerTemplateConfigurator<H> withPack(OldContainerTemplateLink channel) {
123-
PackedContainerTemplatePackList tunnels = pbt.links.add((PackedContainerLink) channel);
124-
this.pbt = new PackedContainerTemplate<>(pbt.kind, pbt.holderClass, tunnels, pbt.resultType, pbt.componentTags, pbt.isManaged);
125-
return this;
126-
}
101+
/** {@inheritDoc} */
102+
@Override
103+
public PackedContainerTemplate<H> withPack(OldContainerTemplateLink channel) {
104+
PackedContainerTemplatePackList tunnels = links.add((PackedContainerLink) channel);
105+
return new PackedContainerTemplate<>(kind, holderClass, tunnels, resultType, componentTags, isManaged);
106+
}
127107

128-
public PackedContainerTemplateConfigurator<H> withWirelets(Wirelet... wirelets) {
129-
throw new UnsupportedOperationException();
130-
}
108+
public PackedContainerTemplate<H> withWirelets(Wirelet... wirelets) {
109+
throw new UnsupportedOperationException();
110+
}
131111

132-
/** {@inheritDoc} */
133-
@Override
134-
public Configurator withComponentTag(String... tags) {
135-
this.pbt = new PackedContainerTemplate<>(pbt.kind, pbt.holderClass, pbt.links, pbt.resultType,
136-
ComponentTagHolder.copyAndAdd(pbt.componentTags, tags), pbt.isManaged);
137-
return this;
112+
/** {@inheritDoc} */
113+
@Override
114+
public PackedContainerTemplate<H> withComponentTag(String... tags) {
115+
return new PackedContainerTemplate<>(kind, holderClass, links, resultType, ComponentTagHolder.copyAndAdd(componentTags, tags), isManaged);
138116

139-
}
140117
}
141118

142119
//

0 commit comments

Comments
 (0)