/*
Copyright 2002-2006 The Members of the OSS through Java(TM) Initiative.
All rights reserved. Use is subject to license terms.
 */
package ossj.common.cbe;

import javax.oss.cbe.CharacteristicSpecification;
import ossj.common.Utils;


/**
 * An implementation class for the <CODE>javax.oss.cbe.CharacteristicSpecification</CODE> interface.
 *
 * @see javax.oss.cbe.CharacteristicSpecification
 *
 * @author OSS through Java(tm) Initiative, Vincent Perrot Sun Microsystems Inc.
 * @version 1.3
 * @since January 2006
 */


public class CharacteristicSpecificationImpl
        implements CharacteristicSpecification {
    
    /**
     * Constructs a new CharacteristicSpecificationImpl with empty attributes.
     */
    
    public CharacteristicSpecificationImpl() {
    }
    
    /**
     * Constructs a new CharacteristicSpecificationImpl with empty attributes.
     * 
     * 
     * @param attribute name
     * @param attribute type (equal top getClass().getName())
     * @param attribute description
     */
    
    public CharacteristicSpecificationImpl(String name, String type, String description) {
        _characteristicimpl_description = description;
        _characteristicimpl_name = name;
        _characteristicimpl_type = type;
    }
    
    private java.lang.String _characteristicimpl_description = "";
    private java.lang.String _characteristicimpl_name = "";
    private java.lang.String _characteristicimpl_type = "";
    
    
    /**
     * Changes the description to be equal to the given argument.
     *
     * This method support a null argument.
     *
     * @param value the new description for this object.
     * @exception java.lang.IllegalArgumentException - Is thrown to report
     * that a bad argument was provided to the method.
     */
    
    public void setDescription(java.lang.String value)
    throws java.lang.IllegalArgumentException    {
        if (value == null)
            throw new java.lang.IllegalArgumentException("null value is not supported.");
        _characteristicimpl_description = value;
    }
    
    
    /**
     * Returns this CharacteristicSpecificationImpl's description
     * 
     * 
     * @return the description
     */
    
    public java.lang.String getDescription() {
        return _characteristicimpl_description;
    }
    
    /**
     * Changes the name to be equal to the given argument.
     *
     * This method support a null argument.
     *
     * @param value the new name for this object.
     * @exception java.lang.IllegalArgumentException - Is thrown to report
     * that a bad argument was provided to the method.
     */
    
    public void setName(java.lang.String value)
    throws java.lang.IllegalArgumentException    {
        if (value == null)
            throw new java.lang.IllegalArgumentException("null value is not supported.");
        _characteristicimpl_name = value;
    }
    
    
    /**
     * Returns this CharacteristicSpecificationImpl's name
     * 
     * 
     * @return the name
     */
    
    public java.lang.String getName() {
        return _characteristicimpl_name;
    }
    
    /**
     * Changes the type to be equal to the given argument.
     *
     * This method support a null argument.
     *
     * @param value the new type for this object.
     * @exception java.lang.IllegalArgumentException - Is thrown to report
     * that a bad argument was provided to the method.
     */
    
    public void setType(java.lang.String value)
    throws java.lang.IllegalArgumentException    {
        if (value == null)
            throw new java.lang.IllegalArgumentException("null value is not supported.");
        _characteristicimpl_type = value;
    }
    
    
    /**
     * Returns this CharacteristicSpecificationImpl's type
     * 
     * 
     * @return the type
     */
    
    public java.lang.String getType() {
        return _characteristicimpl_type;
    }
    
    /**
     * Creates a new object of the same class and with the same contents as this object.
     * @return a clone of this instance.
     */
    public Object clone() {
        CharacteristicSpecification val = null;
        try {
            val = (CharacteristicSpecification)super.clone();
            
            return val;
        } catch( CloneNotSupportedException ex) {
            throw new RuntimeException("CharacteristicSpecificationImpl: Unable to clone this object: "+ ex.getMessage());
        }
    }
    
    /**
     * Checks whether two CharacteristicSpecification are equal.
     * The result is true if and only if the argument is not null
     * and is an CharacteristicSpecification object that has the arguments.
     *
     * @param value the Object to compare with this CharacteristicSpecification
     * @return if the objects are equal; false otherwise.
     */
    
    public boolean equals(Object value) {
        if ( this == value ){ return true;}
        if ( (value != null) && ( value instanceof CharacteristicSpecification)) {
            CharacteristicSpecification argVal = (CharacteristicSpecification) value;
            if( !Utils.compareAttributes( getDescription(), argVal.getDescription())) { return false; }
            if( !Utils.compareAttributes( getName(), argVal.getName())) { return false; }
            if( !Utils.compareAttributes( getType(), argVal.getType())) { return false; }
            
            return true;
        } else {
            return super.equals(value);
        }
    }
    
}
