From a734b2dfbb030aa4d7af58b3c606341eb193063d Mon Sep 17 00:00:00 2001 From: Yu Kobayashi Date: Sun, 28 Dec 2014 19:51:06 +0900 Subject: [PATCH] Add Tuple1, Tuple3, ... , Tuple9 --- src/main/groovy/lang/Tuple1.java | 33 +++++++++++++++ src/main/groovy/lang/Tuple2.java | 2 + src/main/groovy/lang/Tuple3.java | 43 +++++++++++++++++++ src/main/groovy/lang/Tuple4.java | 48 +++++++++++++++++++++ src/main/groovy/lang/Tuple5.java | 53 +++++++++++++++++++++++ src/main/groovy/lang/Tuple6.java | 58 +++++++++++++++++++++++++ src/main/groovy/lang/Tuple7.java | 63 +++++++++++++++++++++++++++ src/main/groovy/lang/Tuple8.java | 68 +++++++++++++++++++++++++++++ src/main/groovy/lang/Tuple9.java | 73 ++++++++++++++++++++++++++++++++ 9 files changed, 441 insertions(+) create mode 100644 src/main/groovy/lang/Tuple1.java create mode 100644 src/main/groovy/lang/Tuple3.java create mode 100644 src/main/groovy/lang/Tuple4.java create mode 100644 src/main/groovy/lang/Tuple5.java create mode 100644 src/main/groovy/lang/Tuple6.java create mode 100644 src/main/groovy/lang/Tuple7.java create mode 100644 src/main/groovy/lang/Tuple8.java create mode 100644 src/main/groovy/lang/Tuple9.java diff --git a/src/main/groovy/lang/Tuple1.java b/src/main/groovy/lang/Tuple1.java new file mode 100644 index 0000000000..ef40d143b9 --- /dev/null +++ b/src/main/groovy/lang/Tuple1.java @@ -0,0 +1,33 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 1 typed Object. + * + * @since 2.4.0 + */ +public class Tuple1 extends Tuple { + public Tuple1(T1 first) { + super(new Object[]{first}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } +} diff --git a/src/main/groovy/lang/Tuple2.java b/src/main/groovy/lang/Tuple2.java index cefa363703..2e9a3be972 100644 --- a/src/main/groovy/lang/Tuple2.java +++ b/src/main/groovy/lang/Tuple2.java @@ -17,6 +17,8 @@ /** * Represents a list of 2 typed Objects. + * + * @since 2.4.0 */ public class Tuple2 extends Tuple { public Tuple2(T1 first, T2 second) { diff --git a/src/main/groovy/lang/Tuple3.java b/src/main/groovy/lang/Tuple3.java new file mode 100644 index 0000000000..d62e5cf189 --- /dev/null +++ b/src/main/groovy/lang/Tuple3.java @@ -0,0 +1,43 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 3 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple3 extends Tuple { + public Tuple3(T1 first, T2 second, T3 third) { + super(new Object[]{first, second, third}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } +} diff --git a/src/main/groovy/lang/Tuple4.java b/src/main/groovy/lang/Tuple4.java new file mode 100644 index 0000000000..733a548708 --- /dev/null +++ b/src/main/groovy/lang/Tuple4.java @@ -0,0 +1,48 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 4 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple4 extends Tuple { + public Tuple4(T1 first, T2 second, T3 third, T4 fourth) { + super(new Object[]{first, second, third, fourth}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } + + @SuppressWarnings("unchecked") + public T4 getFourth() { + return (T4) get(3); + } +} diff --git a/src/main/groovy/lang/Tuple5.java b/src/main/groovy/lang/Tuple5.java new file mode 100644 index 0000000000..569c0bae0a --- /dev/null +++ b/src/main/groovy/lang/Tuple5.java @@ -0,0 +1,53 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 5 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple5 extends Tuple { + public Tuple5(T1 first, T2 second, T3 third, T4 fourth, T5 fifth) { + super(new Object[]{first, second, third, fourth, fifth}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } + + @SuppressWarnings("unchecked") + public T4 getFourth() { + return (T4) get(3); + } + + @SuppressWarnings("unchecked") + public T5 getFifth() { + return (T5) get(4); + } +} diff --git a/src/main/groovy/lang/Tuple6.java b/src/main/groovy/lang/Tuple6.java new file mode 100644 index 0000000000..5a4076e7f4 --- /dev/null +++ b/src/main/groovy/lang/Tuple6.java @@ -0,0 +1,58 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 6 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple6 extends Tuple { + public Tuple6(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth) { + super(new Object[]{first, second, third, fourth, fifth, sixth}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } + + @SuppressWarnings("unchecked") + public T4 getFourth() { + return (T4) get(3); + } + + @SuppressWarnings("unchecked") + public T5 getFifth() { + return (T5) get(4); + } + + @SuppressWarnings("unchecked") + public T6 getSixth() { + return (T6) get(5); + } +} diff --git a/src/main/groovy/lang/Tuple7.java b/src/main/groovy/lang/Tuple7.java new file mode 100644 index 0000000000..0ea21dcff2 --- /dev/null +++ b/src/main/groovy/lang/Tuple7.java @@ -0,0 +1,63 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 7 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple7 extends Tuple { + public Tuple7(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh) { + super(new Object[]{first, second, third, fourth, fifth, sixth, seventh}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } + + @SuppressWarnings("unchecked") + public T4 getFourth() { + return (T4) get(3); + } + + @SuppressWarnings("unchecked") + public T5 getFifth() { + return (T5) get(4); + } + + @SuppressWarnings("unchecked") + public T6 getSixth() { + return (T6) get(5); + } + + @SuppressWarnings("unchecked") + public T7 getSeventh() { + return (T7) get(6); + } +} diff --git a/src/main/groovy/lang/Tuple8.java b/src/main/groovy/lang/Tuple8.java new file mode 100644 index 0000000000..abed559335 --- /dev/null +++ b/src/main/groovy/lang/Tuple8.java @@ -0,0 +1,68 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 8 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple8 extends Tuple { + public Tuple8(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh, T8 eighth) { + super(new Object[]{first, second, third, fourth, fifth, sixth, seventh, eighth}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } + + @SuppressWarnings("unchecked") + public T4 getFourth() { + return (T4) get(3); + } + + @SuppressWarnings("unchecked") + public T5 getFifth() { + return (T5) get(4); + } + + @SuppressWarnings("unchecked") + public T6 getSixth() { + return (T6) get(5); + } + + @SuppressWarnings("unchecked") + public T7 getSeventh() { + return (T7) get(6); + } + + @SuppressWarnings("unchecked") + public T8 getEighth() { + return (T8) get(7); + } +} diff --git a/src/main/groovy/lang/Tuple9.java b/src/main/groovy/lang/Tuple9.java new file mode 100644 index 0000000000..f8f36ad855 --- /dev/null +++ b/src/main/groovy/lang/Tuple9.java @@ -0,0 +1,73 @@ +/* + * Copyright 2003-2014 the original author or authors. + * + * Licensed 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; + +/** + * Represents a list of 9 typed Objects. + * + * @since 2.4.0 + */ +public class Tuple9 extends Tuple { + public Tuple9(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh, T8 eighth, T9 ninth) { + super(new Object[]{first, second, third, fourth, fifth, sixth, seventh, eighth, ninth}); + } + + @SuppressWarnings("unchecked") + public T1 getFirst() { + return (T1) get(0); + } + + @SuppressWarnings("unchecked") + public T2 getSecond() { + return (T2) get(1); + } + + @SuppressWarnings("unchecked") + public T3 getThird() { + return (T3) get(2); + } + + @SuppressWarnings("unchecked") + public T4 getFourth() { + return (T4) get(3); + } + + @SuppressWarnings("unchecked") + public T5 getFifth() { + return (T5) get(4); + } + + @SuppressWarnings("unchecked") + public T6 getSixth() { + return (T6) get(5); + } + + @SuppressWarnings("unchecked") + public T7 getSeventh() { + return (T7) get(6); + } + + @SuppressWarnings("unchecked") + public T8 getEighth() { + return (T8) get(7); + } + + @SuppressWarnings("unchecked") + public T9 getNinth() { + return (T9) get(8); + } +}