Skip to content

Commit

Permalink
fix cloned.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Oct 6, 2024
1 parent 82747ac commit 4c8e486
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ public final class ServiceRepository<Context, Result>
implements Cloned<ServiceRepository<Context, Result>> {

private final ServicePipeline pipeline;
private final Service<Context, Result> defaultImplementation;
final List<ServiceWrapper<Context, Result>> implementations;
final TypeToken<? extends Service<Context, Result>> serviceType;
final List<ServiceWrapper<Context, Result>> implementations;

private ServiceRepository(
@NotNull final ServicePipeline pipeline,
@NotNull final TypeToken<? extends Service<Context, Result>> serviceType,
@NotNull final List<ServiceWrapper<Context, Result>> implementations
) {
this.pipeline = pipeline;
this.serviceType = serviceType;
this.implementations = implementations;
}

public ServiceRepository(
@NotNull final ServicePipeline pipeline,
Expand All @@ -23,7 +32,6 @@ public ServiceRepository(
) {
this.pipeline = pipeline;
this.serviceType = serviceType;
this.defaultImplementation = defaultImplementation;
this.implementations = new LinkedList<>();
this.implementations.add(
new ServiceWrapper<>(serviceType, defaultImplementation, true, null)
Expand All @@ -33,7 +41,11 @@ public ServiceRepository(
@NotNull
@Override
public ServiceRepository<Context, Result> cloned() {
return new ServiceRepository<>(this.pipeline, this.serviceType, this.defaultImplementation);
return new ServiceRepository<>(
this.pipeline,
this.serviceType,
new LinkedList<>(this.implementations)
);
}

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

0 comments on commit 4c8e486

Please sign in to comment.