| 1 |
import java.io.Serializable; |
| 2 |
import java.util.AbstractCollection; |
| 3 |
import java.util.Iterator; |
| 4 |
import java.util.List; |
| 5 |
import java.util.RandomAccess; |
| 6 |
import java.util.stream.Collector; |
| 7 |
|
| 8 |
@SuppressWarnings({"unchecked", ""}) |
| 9 |
public class Bug14 { |
| 10 |
private static final Collector<Object, ?, ImmutableList<Object>> TO_IMMUTABLE_LIST = |
| 11 |
Collector.of( |
| 12 |
ImmutableList::<Object>builder, |
| 13 |
ImmutableList.Builder::add, |
| 14 |
ImmutableList.Builder::combine, |
| 15 |
ImmutableList.Builder::build); |
| 16 |
|
| 17 |
public abstract static class ImmutableList<E> extends ImmutableCollection<E> |
| 18 |
implements List<E>, RandomAccess { |
| 19 |
public static final class Builder<E> { |
| 20 |
|
| 21 |
public Builder<E> add(E element) { |
| 22 |
return this; |
| 23 |
} |
| 24 |
|
| 25 |
public Builder<E> add(E... elements) { |
| 26 |
return this; |
| 27 |
} |
| 28 |
|
| 29 |
public Builder<E> addAll(Iterator<? extends E> elements) { |
| 30 |
return this; |
| 31 |
} |
| 32 |
|
| 33 |
public ImmutableList<E> build() { |
| 34 |
throw new RuntimeException(); |
| 35 |
} |
| 36 |
|
| 37 |
Builder<E> combine(Builder<E> builder) { |
| 38 |
return this; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
public static <E> Builder<E> builder() { |
| 43 |
return new Builder<E>(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public abstract static class ImmutableCollection<E> extends AbstractCollection<E> |
| 48 |
implements Serializable {} |
| 49 |
} |