| 1535 | private final transient CartesianList<E> delegate; |
| 1536 | |
| 1537 | static <E> Set<List<E>> create(List<? extends Set<? extends E>> sets) { |
| 1538 | ImmutableList.Builder<ImmutableSet<E>> axesBuilder = new ImmutableList.Builder<>(sets.size()); |
| 1539 | for (Set<? extends E> set : sets) { |
| 1540 | ImmutableSet<E> copy = ImmutableSet.copyOf(set); |
| 1541 | if (copy.isEmpty()) { |
| 1542 | return ImmutableSet.of(); |
| 1543 | } |
| 1544 | axesBuilder.add(copy); |
| 1545 | } |
| 1546 | ImmutableList<ImmutableSet<E>> axes = axesBuilder.build(); |
| 1547 | ImmutableList<List<E>> listAxes = |
| 1548 | new ImmutableList<List<E>>() { |
| 1549 | @Override |
| 1550 | public int size() { |
| 1551 | return axes.size(); |
| 1552 | } |
| 1553 | |
| 1554 | @Override |
| 1555 | public List<E> get(int index) { |
| 1556 | return axes.get(index).asList(); |
| 1557 | } |
| 1558 | |
| 1559 | @Override |
| 1560 | boolean isPartialView() { |
| 1561 | return true; |
| 1562 | } |
| 1563 | |
| 1564 | // redeclare to help optimizers with b/310253115 |
| 1565 | @SuppressWarnings("RedundantOverride") |
| 1566 | @Override |
| 1567 | @J2ktIncompatible |
| 1568 | @GwtIncompatible |
| 1569 | Object writeReplace() { |
| 1570 | return super.writeReplace(); |
| 1571 | } |
| 1572 | }; |
| 1573 | return new CartesianSet<E>(axes, new CartesianList<E>(listAxes)); |
| 1574 | } |
| 1575 | |
| 1576 | private CartesianSet(ImmutableList<ImmutableSet<E>> axes, CartesianList<E> delegate) { |
| 1577 | this.axes = axes; |