![JAR search and dependency download from the Maven repository](/logo.png)
org.javatuples.Quintet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javatuples Show documentation
Show all versions of javatuples Show documentation
Java library for tuples in Java.
The newest version!
/*
* =============================================================================
*
* Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org)
*
* 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.javatuples;
import java.util.Collection;
import java.util.Iterator;
import org.javatuples.valueintf.IValue0;
import org.javatuples.valueintf.IValue1;
import org.javatuples.valueintf.IValue2;
import org.javatuples.valueintf.IValue3;
import org.javatuples.valueintf.IValue4;
/**
*
* A tuple of five elements.
*
*
* @since 1.0
*
* @author Daniel Fernández
*
*/
public final class Quintet
extends Tuple
implements IValue0,
IValue1,
IValue2,
IValue3,
IValue4 {
private static final long serialVersionUID = -1579008485383872628L;
private static final int SIZE = 5;
private final A val0;
private final B val1;
private final C val2;
private final D val3;
private final E val4;
public static Quintet with(final A value0, final B value1, final C value2, final D value3, final E value4) {
return new Quintet(value0,value1,value2,value3,value4);
}
/**
*
* Create tuple from array. Array has to have exactly five elements.
*
*
* @param the array component type
* @param array the array to be converted to a tuple
* @return the tuple
*/
public static Quintet fromArray(final X[] array) {
if (array == null) {
throw new IllegalArgumentException("Array cannot be null");
}
if (array.length != 5) {
throw new IllegalArgumentException("Array must have exactly 5 elements in order to create a Quintet. Size is " + array.length);
}
return new Quintet(
array[0],array[1],array[2],array[3],array[4]);
}
/**
*
* Create tuple from collection. Collection has to have exactly five elements.
*
*
* @param the collection component type
* @param collection the collection to be converted to a tuple
* @return the tuple
*/
public static Quintet fromCollection(final Collection collection) {
return fromIterable(collection);
}
/**
*
* Create tuple from iterable. Iterable has to have exactly five elements.
*
*
* @param the iterable component type
* @param iterable the iterable to be converted to a tuple
* @return the tuple
*/
public static Quintet fromIterable(final Iterable iterable) {
return fromIterable(iterable, 0, true);
}
/**
*
* Create tuple from iterable, starting from the specified index. Iterable
* can have more (or less) elements than the tuple to be created.
*
*
* @param the iterable component type
* @param iterable the iterable to be converted to a tuple
* @return the tuple
*/
public static Quintet fromIterable(final Iterable iterable, int index) {
return fromIterable(iterable, index, false);
}
private static Quintet fromIterable(final Iterable iterable, int index, final boolean exactSize) {
if (iterable == null) {
throw new IllegalArgumentException("Iterable cannot be null");
}
boolean tooFewElements = false;
X element0 = null;
X element1 = null;
X element2 = null;
X element3 = null;
X element4 = null;
final Iterator iter = iterable.iterator();
int i = 0;
while (i < index) {
if (iter.hasNext()) {
iter.next();
} else {
tooFewElements = true;
}
i++;
}
if (iter.hasNext()) {
element0 = iter.next();
} else {
tooFewElements = true;
}
if (iter.hasNext()) {
element1 = iter.next();
} else {
tooFewElements = true;
}
if (iter.hasNext()) {
element2 = iter.next();
} else {
tooFewElements = true;
}
if (iter.hasNext()) {
element3 = iter.next();
} else {
tooFewElements = true;
}
if (iter.hasNext()) {
element4 = iter.next();
} else {
tooFewElements = true;
}
if (tooFewElements && exactSize) {
throw new IllegalArgumentException("Not enough elements for creating a Quintet (5 needed)");
}
if (iter.hasNext() && exactSize) {
throw new IllegalArgumentException("Iterable must have exactly 5 available elements in order to create a Quintet.");
}
return new Quintet(
element0, element1, element2, element3, element4);
}
public Quintet(
final A value0,
final B value1,
final C value2,
final D value3,
final E value4) {
super(value0, value1, value2, value3, value4);
this.val0 = value0;
this.val1 = value1;
this.val2 = value2;
this.val3 = value3;
this.val4 = value4;
}
public A getValue0() {
return this.val0;
}
public B getValue1() {
return this.val1;
}
public C getValue2() {
return this.val2;
}
public D getValue3() {
return this.val3;
}
public E getValue4() {
return this.val4;
}
@Override
public int getSize() {
return SIZE;
}
public Sextet addAt0(final X0 value0) {
return new Sextet(
value0, this.val0, this.val1, this.val2, this.val3, this.val4);
}
public Sextet addAt1(final X0 value0) {
return new Sextet(
this.val0, value0, this.val1, this.val2, this.val3, this.val4);
}
public Sextet addAt2(final X0 value0) {
return new Sextet(
this.val0, this.val1, value0, this.val2, this.val3, this.val4);
}
public Sextet addAt3(final X0 value0) {
return new Sextet(
this.val0, this.val1, this.val2, value0, this.val3, this.val4);
}
public Sextet addAt4(final X0 value0) {
return new Sextet(
this.val0, this.val1, this.val2, this.val3, value0, this.val4);
}
public Sextet addAt5(final X0 value0) {
return new Sextet(
this.val0, this.val1, this.val2, this.val3, this.val4, value0);
}
public Septet addAt0(final X0 value0, final X1 value1) {
return new Septet(
value0, value1, this.val0, this.val1, this.val2, this.val3, this.val4);
}
public Septet addAt1(final X0 value0, final X1 value1) {
return new Septet(
this.val0, value0, value1, this.val1, this.val2, this.val3, this.val4);
}
public Septet addAt2(final X0 value0, final X1 value1) {
return new Septet(
this.val0, this.val1, value0, value1, this.val2, this.val3, this.val4);
}
public Septet addAt3(final X0 value0, final X1 value1) {
return new Septet(
this.val0, this.val1, this.val2, value0, value1, this.val3, this.val4);
}
public Septet addAt4(final X0 value0, final X1 value1) {
return new Septet(
this.val0, this.val1, this.val2, this.val3, value0, value1, this.val4);
}
public Septet addAt5(final X0 value0, final X1 value1) {
return new Septet(
this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1);
}
public Octet addAt0(final X0 value0, final X1 value1, final X2 value2) {
return new Octet(
value0, value1, value2, this.val0, this.val1, this.val2, this.val3, this.val4);
}
public Octet addAt1(final X0 value0, final X1 value1, final X2 value2) {
return new Octet(
this.val0, value0, value1, value2, this.val1, this.val2, this.val3, this.val4);
}
public Octet addAt2(final X0 value0, final X1 value1, final X2 value2) {
return new Octet(
this.val0, this.val1, value0, value1, value2, this.val2, this.val3, this.val4);
}
public Octet addAt3(final X0 value0, final X1 value1, final X2 value2) {
return new Octet(
this.val0, this.val1, this.val2, value0, value1, value2, this.val3, this.val4);
}
public Octet addAt4(final X0 value0, final X1 value1, final X2 value2) {
return new Octet(
this.val0, this.val1, this.val2, this.val3, value0, value1, value2, this.val4);
}
public Octet addAt5(final X0 value0, final X1 value1, final X2 value2) {
return new Octet(
this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2);
}
public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return new Ennead(
value0, value1, value2, value3, this.val0, this.val1, this.val2, this.val3, this.val4);
}
public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return new Ennead(
this.val0, value0, value1, value2, value3, this.val1, this.val2, this.val3, this.val4);
}
public Ennead addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return new Ennead(
this.val0, this.val1, value0, value1, value2, value3, this.val2, this.val3, this.val4);
}
public Ennead addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return new Ennead(
this.val0, this.val1, this.val2, value0, value1, value2, value3, this.val3, this.val4);
}
public Ennead addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return new Ennead(
this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, this.val4);
}
public Ennead addAt5(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return new Ennead(
this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, value3);
}
public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return new Decade(
value0, value1, value2, value3, value4, this.val0, this.val1, this.val2, this.val3, this.val4);
}
public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return new Decade(
this.val0, value0, value1, value2, value3, value4, this.val1, this.val2, this.val3, this.val4);
}
public Decade addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return new Decade(
this.val0, this.val1, value0, value1, value2, value3, value4, this.val2, this.val3, this.val4);
}
public Decade addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return new Decade(
this.val0, this.val1, this.val2, value0, value1, value2, value3, value4, this.val3, this.val4);
}
public Decade addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return new Decade(
this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, value4, this.val4);
}
public Decade addAt5(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return new Decade(
this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, value3, value4);
}
public Sextet addAt0(final Unit tuple) {
return addAt0(tuple.getValue0());
}
public Sextet addAt1(final Unit tuple) {
return addAt1(tuple.getValue0());
}
public Sextet addAt2(final Unit tuple) {
return addAt2(tuple.getValue0());
}
public Sextet addAt3(final Unit tuple) {
return addAt3(tuple.getValue0());
}
public Sextet addAt4(final Unit tuple) {
return addAt4(tuple.getValue0());
}
public Sextet addAt5(final Unit tuple) {
return addAt5(tuple.getValue0());
}
public Septet addAt0(final Pair tuple) {
return addAt0(tuple.getValue0(),tuple.getValue1());
}
public Septet addAt1(final Pair tuple) {
return addAt1(tuple.getValue0(),tuple.getValue1());
}
public Septet addAt2(final Pair tuple) {
return addAt2(tuple.getValue0(),tuple.getValue1());
}
public Septet addAt3(final Pair tuple) {
return addAt3(tuple.getValue0(),tuple.getValue1());
}
public Septet addAt4(final Pair tuple) {
return addAt4(tuple.getValue0(),tuple.getValue1());
}
public Septet addAt5(final Pair tuple) {
return addAt5(tuple.getValue0(),tuple.getValue1());
}
public Octet addAt0(final Triplet tuple) {
return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2());
}
public Octet addAt1(final Triplet tuple) {
return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2());
}
public Octet addAt2(final Triplet tuple) {
return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2());
}
public Octet addAt3(final Triplet tuple) {
return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2());
}
public Octet addAt4(final Triplet tuple) {
return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2());
}
public Octet addAt5(final Triplet tuple) {
return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2());
}
public Ennead addAt0(final Quartet tuple) {
return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3());
}
public Ennead addAt1(final Quartet tuple) {
return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3());
}
public Ennead addAt2(final Quartet tuple) {
return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3());
}
public Ennead addAt3(final Quartet tuple) {
return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3());
}
public Ennead addAt4(final Quartet tuple) {
return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3());
}
public Ennead addAt5(final Quartet tuple) {
return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3());
}
public Decade addAt0(final Quintet tuple) {
return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4());
}
public Decade addAt1(final Quintet tuple) {
return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4());
}
public Decade addAt2(final Quintet tuple) {
return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4());
}
public Decade addAt3(final Quintet tuple) {
return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4());
}
public Decade addAt4(final Quintet tuple) {
return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4());
}
public Decade addAt5(final Quintet tuple) {
return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4());
}
public Sextet add(final X0 value0) {
return addAt5(value0);
}
public Sextet add(final Unit tuple) {
return addAt5(tuple);
}
public Septet add(final X0 value0, final X1 value1) {
return addAt5(value0, value1);
}
public Septet add(final Pair tuple) {
return addAt5(tuple);
}
public Octet add(final X0 value0, final X1 value1, final X2 value2) {
return addAt5(value0, value1, value2);
}
public Octet add(final Triplet tuple) {
return addAt5(tuple);
}
public Ennead add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) {
return addAt5(value0, value1, value2, value3);
}
public Ennead add(final Quartet tuple) {
return addAt5(tuple);
}
public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) {
return addAt5(value0, value1, value2, value3, value4);
}
public Decade add(final Quintet tuple) {
return addAt5(tuple);
}
public Quintet setAt0(final X value) {
return new Quintet(
value, this.val1, this.val2, this.val3, this.val4);
}
public Quintet setAt1(final X value) {
return new Quintet(
this.val0, value, this.val2, this.val3, this.val4);
}
public Quintet setAt2(final X value) {
return new Quintet(
this.val0, this.val1, value, this.val3, this.val4);
}
public Quintet setAt3(final X value) {
return new Quintet(
this.val0, this.val1, this.val2, value, this.val4);
}
public Quintet setAt4(final X value) {
return new Quintet(
this.val0, this.val1, this.val2, this.val3, value);
}
public Quartet removeFrom0() {
return new Quartet(
this.val1, this.val2, this.val3, this.val4);
}
public Quartet removeFrom1() {
return new Quartet(
this.val0, this.val2, this.val3, this.val4);
}
public Quartet removeFrom2() {
return new Quartet(
this.val0, this.val1, this.val3, this.val4);
}
public Quartet removeFrom3() {
return new Quartet(
this.val0, this.val1, this.val2, this.val4);
}
public Quartet removeFrom4() {
return new Quartet(
this.val0, this.val1, this.val2, this.val3);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy