package org.apache.maven.struts;

/* ====================================================================
 *   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.
 * ====================================================================
 */

/**
 * A class to hold common properties across struts config objects
 *
 * @author  dion
 * @version $Id: ConfigurationEntry.java,v 1.2 2004/03/02 15:36:14 evenisse Exp $
 */
public class ConfigurationEntry
{
    /** Fully qualified Java class name of the implementation class. */
    private String className;
    /** Unique identifier of the form bean, if any, associated with the action
     */
    private String name;

    /** Creates a new instance of ConfigurationEntry */
    public ConfigurationEntry()
    {
    }

    /** Getter for property className.
     * @return Value of property className.
     */
    public String getClassName()
    {
        return className;
    }
    
    /** Setter for property className.
     * @param className New value of property className.
     */
    public void setClassName(String className)
    {
        this.className = className;
    }
    
    /** Getter for property name.
     * @return Value of property name.
     */
    public String getName() 
    {
        return name;
    }
    
    /** Setter for property name.
     * @param name New value of property name.
     */
    public void setName(String name) 
    {
        this.name = name;
    }
    
    /** whether the passed object is the same as this one. In the case of a 
     * config object, the name is the unique qualifier. So two objects are equal
     * if they have equal names
     * @param o any object
     * @return true if o is the same as this object, false otherwise
     */
    public boolean equals(Object o)
    {
        if (o == null)
        {
            return false;
        }
        
        if (getClass() != o.getClass())
        {
            return false;
        }
        
        return getName().equals(((ConfigurationEntry) o).getName());
    }
    
    /** provides the hashCode of this object, which is determined by simply
     * delegating the responsibility to the name property
     * @return the hashCode of the name if not null, otherwise delegate to the
     * parent class
     */
    public int hashCode()
    {
        if (getName() != null)
        {
            return getName().hashCode();
        }
        else
        {
            return super.hashCode();
        }
    }
}
