Skip to content

Commit

Permalink
Clean up ContainerInstances
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Nov 12, 2023
1 parent 28e6129 commit db4714a
Showing 1 changed file with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,11 @@ public ContainerInstances(Object testInstance, ContainerInstances outerInstances
this.instances.add(testInstance);
}

private ContainerInstances(List<Object> instances) {
this.instances = instances;
}

public Object target() {
if (instances.size() > 0) {
return instances.get(instances.size() - 1);
} else {
if (instances.isEmpty()) {
throw new IllegalStateException("No target instance available");
}
}

public Optional<ContainerInstances> outer() {
if (instances.size() > 1) {
List<Object> rest = instances.subList(1, instances.size());
return Optional.of(new ContainerInstances(rest));
} else {
return Optional.empty();
}
return instances.get(instances.size() - 1);
}

/**
Expand Down

0 comments on commit db4714a

Please sign in to comment.