/*******************************************************************************
* Copyright (c) 2009 Neil Bartlett.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Neil Bartlett - initial API and implementation
******************************************************************************/
package com.rabbitmq.client.osgi.common;
public class Pair<A, B> {
private final A fst;
private final B snd;
public Pair(A fst, B snd) {
this.fst = fst;
this.snd = snd;
}
public A getFst() {
return fst;
}
public B getSnd() {
return snd;
}
// hashCode and equals generated by Eclipse
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((fst == null) ? 0 : fst.hashCode());
result = prime * result + ((snd == null) ? 0 : snd.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Pair<?,?> other = (Pair<?,?>) obj;
if (fst == null) {
if (other.fst != null)
return false;
} else if (!fst.equals(other.fst))
return false;
if (snd == null) {
if (other.snd != null)
return false;
} else if (!snd.equals(other.snd))
return false;
return true;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append('(').append(fst).append(',').append(snd).append(')');
return buf.toString();
}
}