/**
 * Copyright (c) 2005-2012 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */
/*
 * Created on 24/09/2005
 */
package org.python.pydev.core;

import java.io.Serializable;

/**
 * Defines a tuple of some object, adding equals and hashCode operations
 * 
 * @author Fabio
 */
public final class TupleN implements Serializable {

    private static final long serialVersionUID = 1L;

    public Object[] o1;

    public TupleN(Object... o1) {
        this.o1 = o1;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof TupleN)) {
            return false;
        }

        TupleN t2 = (TupleN) obj;
        if (t2.o1.length != this.o1.length) {
            return false;
        }
        for (int i = 0; i < o1.length; i++) {
            if (!o1[i].equals(t2.o1[i])) {
                return false;
            }
        }

        return true;
    }

    @Override
    public int hashCode() {
        int ret = 1;
        for (int i = 0; i < o1.length; i++) {
            ret *= o1[i].hashCode();
        }
        return 7 * ret;
    }

    @Override
    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("Tuple [");
        for (int i = 0; i < o1.length; i++) {
            buffer.append(o1[i].toString());
            if (i != o1.length - 1) {
                buffer.append(", ");
            }
        }
        buffer.append("]");
        return buffer.toString();
    }
}

@@ -374,16 +374,41 @@
 lizable;
+%0Aimport java.util.Arrays;
 %0A%0A/**%0A *
@@ -480,17 +480,16 @@
 tions%0A *
- 
 %0A * @aut
@@ -767,32 +767,19 @@
 if (
-!(obj instanceof TupleN)
+this == obj
 ) %7B%0A
@@ -789,36 +789,35 @@
          return 
-fals
+tru
 e;%0A        %7D%0A%0A  
@@ -813,25 +813,24 @@
       %7D%0A
-%0A
         
 TupleN t
@@ -825,209 +825,228 @@
     
-TupleN t2 = (TupleN) obj;%0A        if (t2.o1.length != this.o1.length) %7B%0A            return false;%0A        %7D%0A        for (int i = 0; i %3C o1.length; i++) %7B%0A            if (!o1%5Bi%5D.equals(t2.o1%5Bi%5D
+if (obj == null) %7B%0A            return false;%0A        %7D%0A        if (getClass() != obj.getClass()) %7B%0A            return false;%0A        %7D%0A        TupleN other = (TupleN) obj;%0A        if (!Arrays.deepEquals(o1, other.o1
 )) %7B%0A
-    
     
@@ -1067,30 +1067,16 @@
  false;%0A
-            %7D%0A
         
@@ -1073,25 +1073,24 @@
 ;%0A        %7D%0A
-%0A
         retu
@@ -1159,18 +1159,27 @@
     
-int ret
+final int prime
  = 
+3
 1;%0A 
@@ -1189,80 +1189,78 @@
     
-for (int i = 0; i %3C o1.length; i++) %7B%0A            ret *= o1%5Bi%5D.h
+int result = 1;%0A        result = prime * result + Arrays.deepH
 ashCode(
 );%0A 
@@ -1259,21 +1259,13 @@
 ode(
+o1
 );%0A
-        %7D%0A
     
@@ -1279,14 +1279,13 @@
 urn 
-7 * re
+resul
 t;%0A 
@@ -1496,27 +1496,16 @@
 nd(o1%5Bi%5D
-.toString()
 );%0A     

Support null values in TupleN