io.opentimeline.util.Triplet Maven / Gradle / Ivy
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO Project.
package io.opentimeline.util;
/**
* A generic class that holds a triplet of values.
*
* @param type for first value
* @param type for second value
* @param type for third value
*/
public class Triplet {
private T first;
private U second;
private V third;
public Triplet(T first, U second, V third) {
this.first = first;
this.second = second;
this.third = third;
}
public T getFirst() {
return first;
}
public U getSecond() {
return second;
}
public V getThird() {
return third;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Triplet))
return false;
boolean firstEqual =
(((Triplet) obj).getFirst() == null && ((Triplet) obj).getFirst() == null) ||
((Pair) obj).getFirst().equals(this.getFirst());
boolean secondEqual =
(((Triplet) obj).getSecond() == null && ((Triplet) obj).getSecond() == null) ||
((Triplet) obj).getSecond().equals(this.getSecond());
boolean thirdEqual =
(((Triplet) obj).getThird() == null && ((Triplet) obj).getThird() == null) ||
((Triplet) obj).getThird().equals(this.getThird());
return firstEqual && secondEqual && thirdEqual;
}
@Override
public String toString() {
return this.getClass().getCanonicalName() +
"(" +
"first=" + this.getFirst().toString() +
", second=" + this.getSecond().toString() +
", third=" + this.getThird().toString() +
")";
}
}