You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/09/16 12:04:47 UTC

groovy git commit: Remove AbstractTuple

Repository: groovy
Updated Branches:
  refs/heads/master c9d871690 -> 56b0d4a7d


Remove AbstractTuple


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/56b0d4a7
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/56b0d4a7
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/56b0d4a7

Branch: refs/heads/master
Commit: 56b0d4a7d16472415b69cf3b58607e8e5a80fb3a
Parents: c9d8716
Author: sunlan <su...@apache.org>
Authored: Sat Sep 16 20:04:25 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Sep 16 20:04:25 2017 +0800

----------------------------------------------------------------------
 src/main/groovy/lang/AbstractTuple.java | 61 ----------------------------
 src/main/groovy/lang/Tuple.java         | 36 +++++++++++++++-
 2 files changed, 35 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/56b0d4a7/src/main/groovy/lang/AbstractTuple.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/AbstractTuple.java b/src/main/groovy/lang/AbstractTuple.java
deleted file mode 100644
index c0e0845..0000000
--- a/src/main/groovy/lang/AbstractTuple.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package groovy.lang;
-
-import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
-
-import java.util.AbstractList;
-
-/**
- * @since 2.5.0
- */
-public abstract class AbstractTuple<E> extends AbstractList<E> {
-    private int hashCode;
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || !(o instanceof AbstractTuple)) return false;
-
-        AbstractTuple that = (AbstractTuple) o;
-        if (size() != that.size()) return false;
-        for (int i = 0; i < size(); i++) {
-            if (!DefaultTypeTransformation.compareEqual(get(i), that.get(i))) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        if (hashCode == 0) {
-            for (int i = 0; i < size(); i++) {
-                Object value = get(i);
-                int hash = (value != null) ? value.hashCode() : 0xbabe;
-                hashCode ^= hash;
-            }
-            if (hashCode == 0) {
-                hashCode = 0xbabe;
-            }
-        }
-        return hashCode;
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/56b0d4a7/src/main/groovy/lang/Tuple.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Tuple.java b/src/main/groovy/lang/Tuple.java
index 38d835d..06d501a 100644
--- a/src/main/groovy/lang/Tuple.java
+++ b/src/main/groovy/lang/Tuple.java
@@ -18,6 +18,9 @@
  */
 package groovy.lang;
 
+import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
+
+import java.util.AbstractList;
 import java.util.List;
 
 /**
@@ -25,8 +28,9 @@ import java.util.List;
  * 
  * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
  */
-public class Tuple<E> extends AbstractTuple<E> {
+public class Tuple<E> extends AbstractList<E> {
     private final E[] contents;
+    private int hashCode;
 
     public Tuple(E... contents) {
         if (contents == null) throw new NullPointerException();
@@ -54,4 +58,34 @@ public class Tuple<E> extends AbstractTuple<E> {
     public Tuple<E> subTuple(int fromIndex, int toIndex) {
         return (Tuple<E>) subList(fromIndex, toIndex);
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || !(o instanceof Tuple)) return false;
+
+        Tuple that = (Tuple) o;
+        if (size() != that.size()) return false;
+        for (int i = 0; i < size(); i++) {
+            if (!DefaultTypeTransformation.compareEqual(get(i), that.get(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        if (hashCode == 0) {
+            for (int i = 0; i < size(); i++) {
+                Object value = get(i);
+                int hash = (value != null) ? value.hashCode() : 0xbabe;
+                hashCode ^= hash;
+            }
+            if (hashCode == 0) {
+                hashCode = 0xbabe;
+            }
+        }
+        return hashCode;
+    }
 }