Represents a list of Objects.
| 32 | * Represents a list of Objects. |
| 33 | */ |
| 34 | public class Tuple<E> extends AbstractList<E> implements Serializable, Cloneable, Comparable<Tuple<E>>, RandomAccess { |
| 35 | @Serial private static final long serialVersionUID = -6707770506387821031L; |
| 36 | private final E[] contents; |
| 37 | |
| 38 | /** |
| 39 | * Creates a tuple containing the supplied elements. |
| 40 | * |
| 41 | * @param contents the tuple elements |
| 42 | */ |
| 43 | @SafeVarargs |
| 44 | public Tuple(E... contents) { |
| 45 | if (contents == null) throw new NullPointerException(); |
| 46 | this.contents = contents; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Creates a tuple from the supplied tuple. |
| 51 | * |
| 52 | * @param tuple the source tuple |
| 53 | */ |
| 54 | public Tuple(Tuple<E> tuple) { |
| 55 | this.contents = tuple.contents; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * {@inheritDoc} |
| 60 | */ |
| 61 | @Override |
| 62 | public E get(int index) { |
| 63 | return contents[index]; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * {@inheritDoc} |
| 68 | */ |
| 69 | @Override |
| 70 | public int size() { |
| 71 | return contents.length; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * {@inheritDoc} |
| 76 | */ |
| 77 | @SuppressWarnings("unchecked") |
| 78 | @Override |
| 79 | public E[] toArray() { |
| 80 | int size = size(); |
| 81 | E[] copy = (E[]) new Object[size]; |
| 82 | System.arraycopy(contents, 0, copy, 0, size); |
| 83 | return copy; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * {@inheritDoc} |
| 88 | */ |
| 89 | @SuppressWarnings("unchecked") |
| 90 | @Override |
| 91 | public <T> T[] toArray(T[] a) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…