21 package org.matsim.core.utils.collections;
23 import java.io.Serializable;
36 public final class Tuple<A, B>
implements Serializable {
56 public Tuple(
final A first,
final B second) {
73 public boolean equals(
final Object other) {
74 if (!(other instanceof
Tuple))
return false;
75 Tuple o = (
Tuple) other;
76 if (this.first != null && this.second != null && o.
first != null && o.
second != null) {
77 return (this.first.equals(o.
first) && this.second.equals(o.
second));
79 boolean firstEquals = (this.first == null) && (o.
first == null);
80 boolean secondEquals = (this.second == null) && (o.
second == null);
81 if (!firstEquals && this.first != null && o.
first != null) {
82 firstEquals = this.first.equals(o.
first);
84 if (!secondEquals && this.second != null && o.
second != null) {
85 secondEquals = this.second.equals(o.
second);
87 return firstEquals && secondEquals;
95 return (this.first == null ? 0 : this.first.hashCode()) +
96 (this.second == null ? 0 : this.second.hashCode());
104 StringBuilder buffer =
new StringBuilder(50);
105 buffer.append(
"[Tuple: [First: " );
106 buffer.append(this.first.toString());
107 buffer.append(
"], [Second: ");
108 buffer.append(this.second.toString());
110 return buffer.toString();
boolean equals(final Object other)
static final long serialVersionUID
static< A, B > Tuple< A, B > of(final A first, final B second)
Tuple(final A first, final B second)