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

com.github.bingoohuang.utils.tuple.Tuple8 Maven / Gradle / Ivy

The newest version!
package com.github.bingoohuang.utils.tuple;


import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * A tuple that holds two non-null values.
 *
 * @param  The type of the first nullable value held by this tuple
 * @param  The type of the second nullable value held by this tuple
 * @param  The type of the third nullable value held by this tuple
 * @param  The type of the fourth nullable value held by this tuple
 * @param  The type of the fifth nullable value held by this tuple
 * @param  The type of the sixth value held by this tuple
 * @param  The type of the seventh value held by this tuple
 * @param  The type of the eighth value held by this tuple
 */
@Getter @Setter @EqualsAndHashCode(callSuper = true) @NoArgsConstructor
public class Tuple8 extends Tuple7 {
    T8 t8;

    public Tuple8(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) {
        super(t1, t2, t3, t4, t5, t6, t7);
        this.t8 = t8;
    }

    /**
     * Get the object at the given index.
     *
     * @param index The index of the object to retrieve. Starts at 0.
     * @return The object or {@literal null} if out of bounds.
     */
    public Object get(int index) {
        switch (index) {
            case 7:
                return t8;
            default:
                return super.get(index);
        }
    }

    /**
     * Turn this {@literal Tuples} into a plain Object array.
     *
     * @return A new Object array.
     */
    public Object[] toArray() {
        return new Object[]{t1, t2, t3, t4, t5, t6, t7, t8};
    }

    /**
     * Return the number of elements in this {@literal Tuples}.
     *
     * @return The size of this {@literal Tuples}.
     */
    public int size() {
        return 8;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy