diff --git a/engine/src/main/java/net/jqwik/engine/execution/lifecycle/ContainerInstances.java b/engine/src/main/java/net/jqwik/engine/execution/lifecycle/ContainerInstances.java index 2d0a52914..b55d108a1 100644 --- a/engine/src/main/java/net/jqwik/engine/execution/lifecycle/ContainerInstances.java +++ b/engine/src/main/java/net/jqwik/engine/execution/lifecycle/ContainerInstances.java @@ -18,25 +18,11 @@ public ContainerInstances(Object testInstance, ContainerInstances outerInstances this.instances.add(testInstance); } - private ContainerInstances(List 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 outer() { - if (instances.size() > 1) { - List rest = instances.subList(1, instances.size()); - return Optional.of(new ContainerInstances(rest)); - } else { - return Optional.empty(); - } + return instances.get(instances.size() - 1); } /**