All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.envers.tools.Pair Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha3
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.hibernate.envers.tools;

/**
 * A pair of objects.
 *
 * @param 
 * @param 
 *
 * @author Adam Warski ([email protected])
 */
public class Pair {
	private final T1 obj1;
	private final T2 obj2;

	public Pair(T1 obj1, T2 obj2) {
		this.obj1 = obj1;
		this.obj2 = obj2;
	}

	public T1 getFirst() {
		return obj1;
	}

	public T2 getSecond() {
		return obj2;
	}

	@Override
	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( !(o instanceof Pair) ) {
			return false;
		}

		final Pair pair = (Pair) o;

		if ( obj1 != null ? !obj1.equals( pair.obj1 ) : pair.obj1 != null ) {
			return false;
		}
		if ( obj2 != null ? !obj2.equals( pair.obj2 ) : pair.obj2 != null ) {
			return false;
		}

		return true;
	}

	@Override
	public int hashCode() {
		int result;
		result = (obj1 != null ? obj1.hashCode() : 0);
		result = 31 * result + (obj2 != null ? obj2.hashCode() : 0);
		return result;
	}

	public static  Pair make(T1 obj1, T2 obj2) {
		return new Pair( obj1, obj2 );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy