/*
 *    GeoTools - OpenSource mapping toolkit
 *    http://geotools.org
 *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library 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.
 */
package org.geotools.data.vpf;

import org.geotools.feature.AttributeType;

/**
 * This class encapsulates a join between two columns. It was originally intended to
 * join two VPFColumn types, but there should not be anything about it which
 * constrains it to those two types.
 * @author <a href="mailto:jeff@ionicenterprise.com">Jeff Yutzler</a>
 *
 * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/vpf/src/main/java/org/geotools/data/vpf/ColumnPair.java $
 */
class ColumnPair {
    /**
     * The first column to join
     */
    public AttributeType column1;
    /**
     * The second column to join
     */
    public AttributeType column2;
    /**
     * The only constructor
     * @param c1 the first column
     * @param c2 the second column
     */
    public ColumnPair(AttributeType c1, AttributeType c2) {
        column1 = c1;
        column2 = c2;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        int result = 78236951;
        if (column1 !=null)   result = result * 37 + column1.hashCode();
        if (column2 !=null)   result ^= result *37 + column2.hashCode();

        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object arg0) {
        boolean result = false;

        if (arg0 == this) {
            result = true;
        } else {
            ColumnPair columnPair = (ColumnPair) arg0;

            if ((columnPair != null) && columnPair.column1.equals(this.column1)
                    && columnPair.column2.equals(this.column2)) {
                result = true;
            }
        }

        return result;
    }
}
