Skip to content

Commit 89718bc

Browse files
authored
fix cloned. (#10)
1 parent 82747ac commit 89718bc

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

common/src/main/java/net/infumia/frame/service/ServiceRepository.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@ public final class ServiceRepository<Context, Result>
1212
implements Cloned<ServiceRepository<Context, Result>> {
1313

1414
private final ServicePipeline pipeline;
15-
private final Service<Context, Result> defaultImplementation;
16-
final List<ServiceWrapper<Context, Result>> implementations;
1715
final TypeToken<? extends Service<Context, Result>> serviceType;
16+
final List<ServiceWrapper<Context, Result>> implementations;
17+
18+
private ServiceRepository(
19+
@NotNull final ServicePipeline pipeline,
20+
@NotNull final TypeToken<? extends Service<Context, Result>> serviceType,
21+
@NotNull final List<ServiceWrapper<Context, Result>> implementations
22+
) {
23+
this.pipeline = pipeline;
24+
this.serviceType = serviceType;
25+
this.implementations = implementations;
26+
}
1827

1928
public ServiceRepository(
2029
@NotNull final ServicePipeline pipeline,
@@ -23,7 +32,6 @@ public ServiceRepository(
2332
) {
2433
this.pipeline = pipeline;
2534
this.serviceType = serviceType;
26-
this.defaultImplementation = defaultImplementation;
2735
this.implementations = new LinkedList<>();
2836
this.implementations.add(
2937
new ServiceWrapper<>(serviceType, defaultImplementation, true, null)
@@ -33,7 +41,11 @@ public ServiceRepository(
3341
@NotNull
3442
@Override
3543
public ServiceRepository<Context, Result> cloned() {
36-
return new ServiceRepository<>(this.pipeline, this.serviceType, this.defaultImplementation);
44+
return new ServiceRepository<>(
45+
this.pipeline,
46+
this.serviceType,
47+
new LinkedList<>(this.implementations)
48+
);
3749
}
3850

3951
public void apply(@NotNull final Implementation<Context, Result> operation) {

0 commit comments

Comments
 (0)