
org.jooq.lambda.tuple.Tuple8 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jool Show documentation
Show all versions of jool Show documentation
jOOλ is part of the jOOQ series (along with jOOQ, jOOX, jOOR, jOOU) providing some useful extensions to Java 8 lambdas.
/**
* Copyright (c) 2014-2016, Data Geekery GmbH, [email protected]
*
* 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 org.jooq.lambda.tuple;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import org.jooq.lambda.Seq;
import org.jooq.lambda.function.Function1;
import org.jooq.lambda.function.Function8;
/**
* A tuple of degree 8.
*
* @author Lukas Eder
*/
public class Tuple8 implements Tuple, Comparable>, Serializable, Cloneable {
private static final long serialVersionUID = 1L;
public final T1 v1;
public final T2 v2;
public final T3 v3;
public final T4 v4;
public final T5 v5;
public final T6 v6;
public final T7 v7;
public final T8 v8;
public T1 v1() {
return v1;
}
public T2 v2() {
return v2;
}
public T3 v3() {
return v3;
}
public T4 v4() {
return v4;
}
public T5 v5() {
return v5;
}
public T6 v6() {
return v6;
}
public T7 v7() {
return v7;
}
public T8 v8() {
return v8;
}
public Tuple8(Tuple8 tuple) {
this.v1 = tuple.v1;
this.v2 = tuple.v2;
this.v3 = tuple.v3;
this.v4 = tuple.v4;
this.v5 = tuple.v5;
this.v6 = tuple.v6;
this.v7 = tuple.v7;
this.v8 = tuple.v8;
}
public Tuple8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.v5 = v5;
this.v6 = v6;
this.v7 = v7;
this.v8 = v8;
}
/**
* Concatenate a value to this tuple.
*/
public final Tuple9 concat(T9 value) {
return new Tuple9<>(v1, v2, v3, v4, v5, v6, v7, v8, value);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple9 concat(Tuple1 tuple) {
return new Tuple9<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple10 concat(Tuple2 tuple) {
return new Tuple10<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple11 concat(Tuple3 tuple) {
return new Tuple11<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2, tuple.v3);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple12 concat(Tuple4 tuple) {
return new Tuple12<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2, tuple.v3, tuple.v4);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple13 concat(Tuple5 tuple) {
return new Tuple13<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2, tuple.v3, tuple.v4, tuple.v5);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple14 concat(Tuple6 tuple) {
return new Tuple14<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2, tuple.v3, tuple.v4, tuple.v5, tuple.v6);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple15 concat(Tuple7 tuple) {
return new Tuple15<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2, tuple.v3, tuple.v4, tuple.v5, tuple.v6, tuple.v7);
}
/**
* Concatenate a tuple to this tuple.
*/
public final Tuple16 concat(Tuple8 tuple) {
return new Tuple16<>(v1, v2, v3, v4, v5, v6, v7, v8, tuple.v1, tuple.v2, tuple.v3, tuple.v4, tuple.v5, tuple.v6, tuple.v7, tuple.v8);
}
/**
* Split this tuple into two tuples of degree 0 and 8.
*/
public final Tuple2> split0() {
return new Tuple2<>(limit0(), skip0());
}
/**
* Split this tuple into two tuples of degree 1 and 7.
*/
public final Tuple2, Tuple7> split1() {
return new Tuple2<>(limit1(), skip1());
}
/**
* Split this tuple into two tuples of degree 2 and 6.
*/
public final Tuple2, Tuple6> split2() {
return new Tuple2<>(limit2(), skip2());
}
/**
* Split this tuple into two tuples of degree 3 and 5.
*/
public final Tuple2, Tuple5> split3() {
return new Tuple2<>(limit3(), skip3());
}
/**
* Split this tuple into two tuples of degree 4 and 4.
*/
public final Tuple2, Tuple4> split4() {
return new Tuple2<>(limit4(), skip4());
}
/**
* Split this tuple into two tuples of degree 5 and 3.
*/
public final Tuple2, Tuple3> split5() {
return new Tuple2<>(limit5(), skip5());
}
/**
* Split this tuple into two tuples of degree 6 and 2.
*/
public final Tuple2, Tuple2> split6() {
return new Tuple2<>(limit6(), skip6());
}
/**
* Split this tuple into two tuples of degree 7 and 1.
*/
public final Tuple2, Tuple1> split7() {
return new Tuple2<>(limit7(), skip7());
}
/**
* Split this tuple into two tuples of degree 8 and 0.
*/
public final Tuple2, Tuple0> split8() {
return new Tuple2<>(limit8(), skip8());
}
/**
* Limit this tuple to degree 0.
*/
public final Tuple0 limit0() {
return new Tuple0();
}
/**
* Limit this tuple to degree 1.
*/
public final Tuple1 limit1() {
return new Tuple1<>(v1);
}
/**
* Limit this tuple to degree 2.
*/
public final Tuple2 limit2() {
return new Tuple2<>(v1, v2);
}
/**
* Limit this tuple to degree 3.
*/
public final Tuple3 limit3() {
return new Tuple3<>(v1, v2, v3);
}
/**
* Limit this tuple to degree 4.
*/
public final Tuple4 limit4() {
return new Tuple4<>(v1, v2, v3, v4);
}
/**
* Limit this tuple to degree 5.
*/
public final Tuple5 limit5() {
return new Tuple5<>(v1, v2, v3, v4, v5);
}
/**
* Limit this tuple to degree 6.
*/
public final Tuple6 limit6() {
return new Tuple6<>(v1, v2, v3, v4, v5, v6);
}
/**
* Limit this tuple to degree 7.
*/
public final Tuple7 limit7() {
return new Tuple7<>(v1, v2, v3, v4, v5, v6, v7);
}
/**
* Limit this tuple to degree 8.
*/
public final Tuple8 limit8() {
return this;
}
/**
* Skip 0 degrees from this tuple.
*/
public final Tuple8 skip0() {
return this;
}
/**
* Skip 1 degrees from this tuple.
*/
public final Tuple7 skip1() {
return new Tuple7<>(v2, v3, v4, v5, v6, v7, v8);
}
/**
* Skip 2 degrees from this tuple.
*/
public final Tuple6 skip2() {
return new Tuple6<>(v3, v4, v5, v6, v7, v8);
}
/**
* Skip 3 degrees from this tuple.
*/
public final Tuple5 skip3() {
return new Tuple5<>(v4, v5, v6, v7, v8);
}
/**
* Skip 4 degrees from this tuple.
*/
public final Tuple4 skip4() {
return new Tuple4<>(v5, v6, v7, v8);
}
/**
* Skip 5 degrees from this tuple.
*/
public final Tuple3 skip5() {
return new Tuple3<>(v6, v7, v8);
}
/**
* Skip 6 degrees from this tuple.
*/
public final Tuple2 skip6() {
return new Tuple2<>(v7, v8);
}
/**
* Skip 7 degrees from this tuple.
*/
public final Tuple1 skip7() {
return new Tuple1<>(v8);
}
/**
* Skip 8 degrees from this tuple.
*/
public final Tuple0 skip8() {
return new Tuple0();
}
/**
* Apply this tuple as arguments to a function.
*/
public final R map(Function8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> function) {
return function.apply(this);
}
/**
* Apply attribute 1 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map1(Function1 super T1, ? extends U1> function) {
return Tuple.tuple(function.apply(v1), v2, v3, v4, v5, v6, v7, v8);
}
/**
* Apply attribute 2 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map2(Function1 super T2, ? extends U2> function) {
return Tuple.tuple(v1, function.apply(v2), v3, v4, v5, v6, v7, v8);
}
/**
* Apply attribute 3 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map3(Function1 super T3, ? extends U3> function) {
return Tuple.tuple(v1, v2, function.apply(v3), v4, v5, v6, v7, v8);
}
/**
* Apply attribute 4 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map4(Function1 super T4, ? extends U4> function) {
return Tuple.tuple(v1, v2, v3, function.apply(v4), v5, v6, v7, v8);
}
/**
* Apply attribute 5 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map5(Function1 super T5, ? extends U5> function) {
return Tuple.tuple(v1, v2, v3, v4, function.apply(v5), v6, v7, v8);
}
/**
* Apply attribute 6 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map6(Function1 super T6, ? extends U6> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, function.apply(v6), v7, v8);
}
/**
* Apply attribute 7 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map7(Function1 super T7, ? extends U7> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, v6, function.apply(v7), v8);
}
/**
* Apply attribute 8 as argument to a function and return a new tuple with the substituted argument.
*/
public final Tuple8 map8(Function1 super T8, ? extends U8> function) {
return Tuple.tuple(v1, v2, v3, v4, v5, v6, v7, function.apply(v8));
}
@Override
@Deprecated
public final Object[] array() {
return toArray();
}
@Override
public final Object[] toArray() {
return new Object[] { v1, v2, v3, v4, v5, v6, v7, v8 };
}
@Override
@Deprecated
public final List> list() {
return toList();
}
@Override
public final List> toList() {
return Arrays.asList(toArray());
}
@Override
public final Seq> toSeq() {
return Seq.seq(toList());
}
@Override
public final Map toMap() {
return toMap(i -> "v" + (i + 1));
}
@Override
public final Map toMap(Function super Integer, ? extends K> keyMapper) {
Map result = new LinkedHashMap<>();
Object[] array = toArray();
for (int i = 0; i < array.length; i++)
result.put(keyMapper.apply(i), array[i]);
return result;
}
public final Map toMap(
Supplier extends K> keySupplier1,
Supplier extends K> keySupplier2,
Supplier extends K> keySupplier3,
Supplier extends K> keySupplier4,
Supplier extends K> keySupplier5,
Supplier extends K> keySupplier6,
Supplier extends K> keySupplier7,
Supplier extends K> keySupplier8
) {
Map result = new LinkedHashMap<>();
result.put(keySupplier1.get(), v1);
result.put(keySupplier2.get(), v2);
result.put(keySupplier3.get(), v3);
result.put(keySupplier4.get(), v4);
result.put(keySupplier5.get(), v5);
result.put(keySupplier6.get(), v6);
result.put(keySupplier7.get(), v7);
result.put(keySupplier8.get(), v8);
return result;
}
public final Map toMap(
K key1,
K key2,
K key3,
K key4,
K key5,
K key6,
K key7,
K key8
) {
Map result = new LinkedHashMap<>();
result.put(key1, v1);
result.put(key2, v2);
result.put(key3, v3);
result.put(key4, v4);
result.put(key5, v5);
result.put(key6, v6);
result.put(key7, v7);
result.put(key8, v8);
return result;
}
/**
* The degree of this tuple: 8.
*/
@Override
public final int degree() {
return 8;
}
@Override
@SuppressWarnings("unchecked")
public final Iterator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy