ma.vi.base.tuple.T4 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.vikmad.base Show documentation
Show all versions of com.vikmad.base Show documentation
Base algos, data structures and utilities
The newest version!
/*
* Copyright (c) 2016 Vikash Madhow
*/
package ma.vi.base.tuple;
/**
* A 4-tuple contains 4 typed objects accessible as the fields a, b, c
* and d.
*
* @author Vikash Madhow ([email protected])
*/
public class T4 extends AbstractTuple {
public T4() {
this(null, null, null, null);
}
public T4(A a, B b, C c, D d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
@Override
public int size() {
return 4;
}
@Override
public Object get(int i) {
return switch (i) {
case 0 -> a;
case 1 -> b;
case 2 -> c;
case 3 -> d;
default -> throw new IndexOutOfBoundsException("Index " + i + " is out of bounds for a " + size() + "-tuple");
};
}
@Override
public T4 clone() throws CloneNotSupportedException {
return (T4) super.clone();
}
public A a() {
return a;
}
public B b() {
return b;
}
public C c() {
return c;
}
public D d() {
return d;
}
public static T4 of(A a, B b, C c, D d) {
return new T4<>(a, b, c, d);
}
public final A a;
public final B b;
public final C c;
public final D d;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy