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 06:42:20 UTC
[2/2] groovy git commit: Generify Tuple
Generify Tuple
(cherry picked from commit 440ae18)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3929d038
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3929d038
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3929d038
Branch: refs/heads/GROOVY_2_6_X
Commit: 3929d0382ac9762e8dde335aa5b734b957d8810a
Parents: 1409796
Author: sunlan <su...@apache.org>
Authored: Sat Sep 16 14:25:39 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Sep 16 14:42:07 2017 +0800
----------------------------------------------------------------------
src/main/groovy/lang/Tuple.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/3929d038/src/main/groovy/lang/Tuple.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Tuple.java b/src/main/groovy/lang/Tuple.java
index 1eeed45..36b04cb 100644
--- a/src/main/groovy/lang/Tuple.java
+++ b/src/main/groovy/lang/Tuple.java
@@ -25,16 +25,16 @@ import java.util.List;
*
* @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
*/
-public class Tuple extends AbstractTuple {
- private final Object[] contents;
+public class Tuple<E> extends AbstractTuple<E> {
+ private final E[] contents;
- public Tuple(Object... contents) {
+ public Tuple(E... contents) {
if (contents == null) throw new NullPointerException();
this.contents = contents;
}
@Override
- public Object get(int index) {
+ public E get(int index) {
return contents[index];
}
@@ -44,10 +44,10 @@ public class Tuple extends AbstractTuple {
}
@Override
- public List subList(int fromIndex, int toIndex) {
+ public List<E> subList(int fromIndex, int toIndex) {
int size = toIndex - fromIndex;
- Object[] newContent = new Object[size];
+ E[] newContent = (E[]) new Object[size];
System.arraycopy(contents, fromIndex, newContent, 0, size);
- return new Tuple(newContent);
+ return new Tuple<>(newContent);
}
}