/*******************************************************************************
 *  Copyright 2017 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 *  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.
 *******************************************************************************/
package cdac.medinfo.sdk.hl7282.baselibs;

import cdac.medinfo.sdk.hl7282.baselibs.segmentfactory.DataElementFactory;
import cdac.medinfo.sdk.hl7282.utils.EnumDataType;
import cdac.medinfo.sdk.hl7282.utils.HL7Constants;

/**
 * TM - Time<p>
 * This data type specifies the hour of the day with optional minutes, seconds, fraction of second using a 24-hour clock notation and time zone.
 * 
 * <p>This class override the equal method, to check whether some other object is "equal to" this one.
 * 
 * <p>User can also create Data Type through {@link DataElementFactory} 
 */
public class TM extends PrimitiveDataType    
{
	

	/**
	 * Constructor for TM class. 
	 */
	public TM()
	{
		super(EnumDataType.HL7_DT_TM);
		this.iDataType = HL7Constants.HL7_DT_TM;
		 
	}

	/**
	 * Constructor for TM class which takes three argument and 
	 * sets the value in the respective member variable.
	 * @param iMinLength The Minimum length the DataType can have.
	 * @param iMaxLength The Maximum length the DataType can have.
	 * @param iCLength The Conformance length the DataType can have.
	 */
	public TM(int iMinLength, int iMaxLength, String strCLength)
	{
		super(EnumDataType.HL7_DT_TM);
		this.iMinLength = iMinLength;
		this.iMaxLength = iMaxLength;
		this.iConformanceLength = strCLength;
		this.iDataType = HL7Constants.HL7_DT_TM;
	}

	/**
	 * Constructor for TM class which takes four arguments and 
	 * sets the value in the respective member variable.
	 * @param iMinLength The Minimum length the DataType can have.
	 * @param iMaxLength The Maximum length the DataType can have.
	 * @param iCLength The Conformance length the DataType can have.
	 * @param iTableNo The Table number to which the value for the component is specified. 
	 */
	public TM(int iMinLength, int iMaxLength, String strCLength,int iTableNo)
	{
		super(EnumDataType.HL7_DT_TM);
		this.iMinLength = iMinLength;
		this.iMaxLength = iMaxLength;
		this.iConformanceLength = strCLength;
		this.iTableNo = iTableNo;
		this.iDataType = HL7Constants.HL7_DT_TM;
	}

	/**
	 * This method checks the equality of Object.
	 * @param objObject object of Object class.
	 * @return boolean - shows success or failure of the comparison.
	 */
	public boolean equals(Object objObject)
	{
		if((objObject == null ) || (!(objObject instanceof TM)))
			return false;

		if(this.getValue() == null)
		{
			if(((TM)objObject).getValue() != null)
				return false;
		}
		else if(false == (this.getValue().equals(((TM)objObject).getValue())))
			return false;

		return true;
	}
}
