blob: d4cea90fbdcd53e96e4dc6c75781abc4d45511f9 [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.falcon;
import java.io.Serializable;
/**
* Simple pair class to hold a pair of object of specific class.
* @param <A> - First element in pair.
* @param <B> - Second element in pair
*/
public class Pair<A, B> implements Serializable {
private static final long serialVersionUID = 1L;
//SUSPEND CHECKSTYLE CHECK VisibilityModifierCheck
public final A first;
public final B second;
//RESUME CHECKSTYLE CHECK VisibilityModifierCheck
public Pair(A fst, B snd) {
this.first = fst;
this.second = snd;
}
public static <A, B> Pair<A, B> of(A a, B b) {
return new Pair<A, B>(a, b);
}
@Override
public String toString() {
return "(" + first + "," + second + ")";
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Pair pair = (Pair) o;
if (first != null ? !first.equals(pair.first) : pair.first != null) {
return false;
}
if (second != null ? !second.equals(pair.second) : pair.second != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = first != null ? first.hashCode() : 0;
result = 31 * result + (second != null ? second.hashCode() : 0);
return result;
}
}