1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import java.io.Serializable;
18  
19  /**
20   * <a href="Tuple.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Alexander Chow
23   */
24  public class Tuple implements Serializable {
25  
26      public Tuple(Object... array) {
27          _array = array;
28      }
29  
30      public Object getObject(int i) {
31          return _array[i];
32      }
33  
34      public boolean equals(Object obj) {
35          if (!(obj instanceof Tuple)) {
36              return false;
37          }
38  
39          Tuple tuple = (Tuple)obj;
40  
41          if (tuple._array.length != _array.length) {
42              return false;
43          }
44  
45          for (int i = 0; i < _array.length; i++) {
46              if ((tuple._array != null) && (_array[i] != null) &&
47                  (!_array[i].equals(tuple._array[i]))) {
48  
49                  return false;
50              }
51              else if ((tuple._array[i] == null) || (_array[i] == null)) {
52                  return false;
53              }
54          }
55  
56          return true;
57      }
58  
59      public int hashCode() {
60          int hashCode = 0;
61  
62          for (int i = 0; i < _array.length; i++) {
63              hashCode = hashCode ^ _array[i].hashCode();
64          }
65  
66          return hashCode;
67      }
68  
69      private Object[] _array;
70  
71  }