package org.apache.maven.linkcheck.validation;

/* ====================================================================
 *   Copyright 2001-2004 The Apache Software Foundation.
 *
 *   Licensed 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.
 * ====================================================================
 */
 
import java.io.File;

/**
 * @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
 * @version $Id$
 */
public class LinkValidationItem {
    private final File source;
    private final String link;
    
    public LinkValidationItem(File source, String link) {
        if (source == null) {
            throw new NullPointerException("source can't be null");
        }
        
        if (link == null) {
            throw new NullPointerException("link can't be null");
        }
        
        this.source = source;
        this.link = link;
    }

    /**
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj) {
        LinkValidationItem lvi = (LinkValidationItem) obj;
        
        if (!lvi.link.equals(link))
            return false;
            
        if (!lvi.source.equals(source))
            return false;
            
        return true;
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return source.hashCode() ^ link.hashCode();
    }

    
    /**
     * Returns the link.
     * @return String
     */
    public String getLink() {
        return link;
    }

    /**
     * Returns the source.
     * @return File
     */
    public File getSource() {
        return source;
    }
    
}
