All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ua.co.gravy.tuplets.Undecuplet Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2017 Vitaliy Berdinskikh
 *
 * 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 ua.co.gravy.tuplets;


import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;


/**
 * Group of eleven.
 *
 * @param  type of first element
 * @param  type of second element
 * @param  type of third element
 * @param  type of fourth element
 * @param  type of fifth element
 * @param  type of sixth element
 * @param 

type of seventh element * @param type of eighth element * @param type of ninth element * @param type of tenth element * @param type of eleventh element * @author Vitaliy Berdinskikh, ur6lad * @since 1.0 */ public final class Undecuplet extends AbstractTuplet { private static final int ARITY = 11; private final S first; private final D second; private final T third; private final A fourth; private final I fifth; private final X sixth; private final P seventh; private final O eighth; private final N ninth; private final E tenth; private final U eleventh; public Undecuplet(S first, D second, T third, A fourth, I fifth, X sixth, P seventh, O eighth, N ninth, E tenth, U eleventh) { this.first = first; this.second = second; this.third = third; this.fourth = fourth; this.fifth = fifth; this.sixth = sixth; this.seventh = seventh; this.eighth = eighth; this.ninth = ninth; this.tenth = tenth; this.eleventh = eleventh; } /** * Get first element. * * @return first element */ public S first() { return first; } /** * Get second element. * * @return second element */ public D second() { return second; } /** * Get third element. * * @return third element */ public T third() { return third; } /** * Get fourth element. * * @return fourth element */ public A fourth() { return fourth; } /** * Get fifth element. * * @return fifth element */ public I fifth() { return fifth; } /** * Get sixth element. * * @return sixth element */ public X sixth() { return sixth; } /** * Get seventh element. * * @return seventh element */ public P seventh() { return seventh; } /** * Get eighth element. * * @return eighth element */ public O eighth() { return eighth; } /** * Get ninth element. * * @return ninth element */ public N ninth() { return ninth; } /** * Get tenth element. * * @return tenth element */ public E tenth() { return tenth; } /** * Get eleventh element. * * @return eleventh element */ public U eleventh() { return eleventh; } @Override public Object get(int index) { Object result; switch(index) { case 0: result = first; break; case 1: result = second; break; case 2: result = third; break; case 3: result = fourth; break; case 4: result = fifth; break; case 5: result = sixth; break; case 6: result = seventh; break; case 7: result = eighth; break; case 8: result = ninth; break; case 9: result = tenth; break; case 10: result = eleventh; break; default: throw new IndexOutOfBoundsException("Index " + index + " is out of bounds of undecuplet!"); } return result; } @Override public int length() { return ARITY; } @Override public Stream stream() { return Stream.of(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } @Override public Object[] toArray() { return new Object[] { first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh }; } @Override public List toList() { return Arrays.asList(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as first element and copy other. * * @param first first element * @return new undecuplet */ public Undecuplet withFirst(S first) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as second element and copy other. * * @param second second element * @return new undecuplet */ public Undecuplet withSecond(D second) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as third element and copy other. * * @param third third element * @return new undecuplet */ public Undecuplet withThird(T third) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as fourth element and copy other. * * @param fourth fourth element * @return new undecuplet */ public Undecuplet withFourth(A fourth) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as fifth element and copy other. * * @param fifth fifth element * @return new undecuplet */ public Undecuplet withFifth(I fifth) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as sixth element and copy other. * * @param sixth sixth element * @return new undecuplet */ public Undecuplet withSixth(X sixth) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as seventh element and copy other. * * @param seventh seventh element * @return new undecuplet */ public Undecuplet withSeventh(P seventh) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as eighth element and copy other. * * @param eighth eighth element * @return new undecuplet */ public Undecuplet withEighth(O eighth) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as ninth element and copy other. * * @param ninth ninth element * @return new undecuplet */ public Undecuplet withNinth(N ninth) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as tenth element and copy other. * * @param tenth tenth element * @return new undecuplet */ public Undecuplet withTenth(E tenth) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } /** * Make new undecuplet: set parameter as eleventh element and copy other. * * @param eleventh eleventh element * @return new undecuplet */ public Undecuplet withEleventh(U eleventh) { return new Undecuplet<>(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh); } }