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:25:59 UTC
groovy git commit: Generify Tuple
Repository: groovy
Updated Branches:
refs/heads/master 0dd461d67 -> 440ae1832
Generify Tuple
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/440ae183
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/440ae183
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/440ae183
Branch: refs/heads/master
Commit: 440ae1832710d26debba3174881ddd3b28f001a4
Parents: 0dd461d
Author: sunlan <su...@apache.org>
Authored: Sat Sep 16 14:25:39 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Sep 16 14:25:39 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/440ae183/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);
}
}