[New] Added TypedTuple.equals and .hashCode()

This commit is contained in:
Robert von Burg 2023-11-28 15:42:22 +01:00
parent 4bee5990ac
commit 7867f206a1
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 19 additions and 4 deletions

View File

@ -15,13 +15,13 @@
*/
package li.strolch.utils.collections;
import java.util.Objects;
/**
* Simple wrapper for two elements
*
* @param <T>
* first object
* @param <U>
* second object
* @param <T> first object
* @param <U> second object
*
* @author Robert von Burg &lt;eitch@eitchnet.ch&gt;
*/
@ -66,4 +66,19 @@ public class TypedTuple<T, U> {
public boolean hasBoth() {
return this.hasFirst() & this.hasSecond();
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
TypedTuple<?, ?> that = (TypedTuple<?, ?>) o;
return Objects.equals(first, that.first) && Objects.equals(second, that.second);
}
@Override
public int hashCode() {
return Objects.hash(first, second);
}
}