View Javadoc
1   package com.github.davidmoten.rx.jdbc.tuple;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   /**
7    * Variable length tuple backed by a List.
8    * 
9    * @param <T>
10   */
11  public class TupleN<T> {
12  
13      private final List<T> list;
14  
15      /**
16       * Constructor.
17       * 
18       * @param list
19       */
20      public TupleN(List<T> list) {
21          this.list = list;
22      }
23  
24      public List<T> values() {
25          // defensive copy
26          return new ArrayList<T>(list);
27      }
28  
29      @Override
30      public int hashCode() {
31          final int prime = 31;
32          int result = 1;
33          result = prime * result + ((list == null) ? 0 : list.hashCode());
34          return result;
35      }
36  
37      @Override
38      public boolean equals(Object obj) {
39          if (this == obj)
40              return true;
41          if (obj == null)
42              return false;
43          if (getClass() != obj.getClass())
44              return false;
45          TupleN<?> other = (TupleN<?>) obj;
46          if (list == null) {
47              if (other.list != null)
48                  return false;
49          } else if (!list.equals(other.list))
50              return false;
51          return true;
52      }
53  
54      @Override
55      public String toString() {
56          return "TupleN [values=" + list + "]";
57      }
58  
59  }