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

ma.vi.base.tuple.T5 Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2016 Vikash Madhow
 */

package ma.vi.base.tuple;

/**
 * A 5-tuple contains 5 typed objects accessible as the fields a, b, c,
 * d and e.
 *
 * @author Vikash Madhow ([email protected])
 */
public class T5 extends AbstractTuple {
  public T5() {
    this(null, null, null, null, null);
  }

  public T5(A a, B b, C c, D d, E e) {
    this.a = a;
    this.b = b;
    this.c = c;
    this.d = d;
    this.e = e;
  }

  @Override
  public int size() {
    return 5;
  }

  @Override
  public Object get(int i) {
    return switch (i) {
      case 0 -> a;
      case 1 -> b;
      case 2 -> c;
      case 3 -> d;
      case 4 -> e;
      default -> throw new IndexOutOfBoundsException("Index " + i + " is out of bounds for a " + size() + "-tuple");
    };
  }

  @Override
  public T5 clone() throws CloneNotSupportedException {
    return (T5) super.clone();
  }

  public A a() {
    return a;
  }

  public B b() {
    return b;
  }

  public C c() {
    return c;
  }

  public D d() {
    return d;
  }

  public E e() {
    return e;
  }

  public static  T5 of(A a, B b, C c, D d, E e) {
    return new T5<>(a, b, c, d, e);
  }

  public final A a;
  public final B b;
  public final C c;
  public final D d;
  public final E e;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy