/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/admin/vo/Opcs4Vo.java
//#############################################################################
//#                                                                           #
//#  Copyright (C) <2015>  <IMS MAXIMS>                                       #
//#                                                                           #
//#  This program is free software: you can redistribute it and/or modify     #
//#  it under the terms of the GNU Affero General Public License as           #
//#  published by the Free Software Foundation, either version 3 of the       #
//#  License, or (at your option) any later version.                          # 
//#                                                                           #
//#  This program 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 Affero General Public License for more details.                      #
//#                                                                           #
//#  You should have received a copy of the GNU Affero General Public License #
//#  along with this program.  If not, see <http://www.gnu.org/licenses/>.    #
//#                                                                           #
//#  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
//#  this program.  Users of this software do so entirely at their own risk.  #
//#  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
//#  software that it builds, deploys and maintains.                          #
//#                                                                           #
//#############################################################################
//#EOH
// This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5589.25814)
// Copyright (C) 1995-2015 IMS MAXIMS. All rights reserved.
// WARNING: DO NOT MODIFY the content of this file

package ims.admin.vo;

/**
 * Linked to core.clinical.coding.Opcs4 business object (ID: 1065100001).
 */
public class Opcs4Vo extends ims.core.clinical.coding.vo.Opcs4RefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public Opcs4Vo()
	{
	}
	public Opcs4Vo(Integer id, int version)
	{
		super(id, version);
	}
	public Opcs4Vo(ims.admin.vo.beans.Opcs4VoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.selindic = bean.getSelindic();
		this.opprefix = bean.getOpprefix();
		this.opcode = bean.getOpcode();
		this.opname3 = bean.getOpname3();
		this.opname4 = bean.getOpname4();
		this.sexa = bean.getSexa();
		this.sexs = bean.getSexs();
		this.opstatus = bean.getOpstatus();
		this.delmetod = bean.getDelmetod();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.Opcs4VoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.selindic = bean.getSelindic();
		this.opprefix = bean.getOpprefix();
		this.opcode = bean.getOpcode();
		this.opname3 = bean.getOpname3();
		this.opname4 = bean.getOpname4();
		this.sexa = bean.getSexa();
		this.sexs = bean.getSexs();
		this.opstatus = bean.getOpstatus();
		this.delmetod = bean.getDelmetod();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.admin.vo.beans.Opcs4VoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.Opcs4VoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.Opcs4VoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public Object getFieldValueByFieldName(String fieldName)
	{
		if(fieldName == null)
			throw new ims.framework.exceptions.CodingRuntimeException("Invalid field name");
		fieldName = fieldName.toUpperCase();
		if(fieldName.equals("SELINDIC"))
			return getSelindic();
		if(fieldName.equals("OPPREFIX"))
			return getOpprefix();
		if(fieldName.equals("OPCODE"))
			return getOpcode();
		if(fieldName.equals("OPNAME3"))
			return getOpname3();
		if(fieldName.equals("OPNAME4"))
			return getOpname4();
		if(fieldName.equals("SEXA"))
			return getSexa();
		if(fieldName.equals("SEXS"))
			return getSexs();
		if(fieldName.equals("OPSTATUS"))
			return getOpstatus();
		if(fieldName.equals("DELMETOD"))
			return getDelmetod();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getSelindicIsNotNull()
	{
		return this.selindic != null;
	}
	public String getSelindic()
	{
		return this.selindic;
	}
	public static int getSelindicMaxLength()
	{
		return 11;
	}
	public void setSelindic(String value)
	{
		this.isValidated = false;
		this.selindic = value;
	}
	public boolean getOpprefixIsNotNull()
	{
		return this.opprefix != null;
	}
	public String getOpprefix()
	{
		return this.opprefix;
	}
	public static int getOpprefixMaxLength()
	{
		return 1;
	}
	public void setOpprefix(String value)
	{
		this.isValidated = false;
		this.opprefix = value;
	}
	public boolean getOpcodeIsNotNull()
	{
		return this.opcode != null;
	}
	public String getOpcode()
	{
		return this.opcode;
	}
	public static int getOpcodeMaxLength()
	{
		return 4;
	}
	public void setOpcode(String value)
	{
		this.isValidated = false;
		this.opcode = value;
	}
	public boolean getOpname3IsNotNull()
	{
		return this.opname3 != null;
	}
	public String getOpname3()
	{
		return this.opname3;
	}
	public static int getOpname3MaxLength()
	{
		return 55;
	}
	public void setOpname3(String value)
	{
		this.isValidated = false;
		this.opname3 = value;
	}
	public boolean getOpname4IsNotNull()
	{
		return this.opname4 != null;
	}
	public String getOpname4()
	{
		return this.opname4;
	}
	public static int getOpname4MaxLength()
	{
		return 60;
	}
	public void setOpname4(String value)
	{
		this.isValidated = false;
		this.opname4 = value;
	}
	public boolean getSexaIsNotNull()
	{
		return this.sexa != null;
	}
	public String getSexa()
	{
		return this.sexa;
	}
	public static int getSexaMaxLength()
	{
		return 1;
	}
	public void setSexa(String value)
	{
		this.isValidated = false;
		this.sexa = value;
	}
	public boolean getSexsIsNotNull()
	{
		return this.sexs != null;
	}
	public String getSexs()
	{
		return this.sexs;
	}
	public static int getSexsMaxLength()
	{
		return 1;
	}
	public void setSexs(String value)
	{
		this.isValidated = false;
		this.sexs = value;
	}
	public boolean getOpstatusIsNotNull()
	{
		return this.opstatus != null;
	}
	public String getOpstatus()
	{
		return this.opstatus;
	}
	public static int getOpstatusMaxLength()
	{
		return 2;
	}
	public void setOpstatus(String value)
	{
		this.isValidated = false;
		this.opstatus = value;
	}
	public boolean getDelmetodIsNotNull()
	{
		return this.delmetod != null;
	}
	public String getDelmetod()
	{
		return this.delmetod;
	}
	public static int getDelmetodMaxLength()
	{
		return 24;
	}
	public void setDelmetod(String value)
	{
		this.isValidated = false;
		this.delmetod = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		this.isBusy = false;
		return true;
	}
	public String[] validate()
	{
		return validate(null);
	}
	public String[] validate(String[] existingErrors)
	{
		if(this.isBusy)
			return null;
		this.isBusy = true;
	
		java.util.ArrayList<String> listOfErrors = new java.util.ArrayList<String>();
		if(existingErrors != null)
		{
			for(int x = 0; x < existingErrors.length; x++)
			{
				listOfErrors.add(existingErrors[x]);
			}
		}
		if(this.selindic != null)
			if(this.selindic.length() > 11)
				listOfErrors.add("The length of the field [selindic] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 11");
		if(this.opprefix != null)
			if(this.opprefix.length() > 1)
				listOfErrors.add("The length of the field [opprefix] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 1");
		if(this.opcode != null)
			if(this.opcode.length() > 4)
				listOfErrors.add("The length of the field [opcode] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 4");
		if(this.opname3 != null)
			if(this.opname3.length() > 55)
				listOfErrors.add("The length of the field [opname3] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 55");
		if(this.opname4 != null)
			if(this.opname4.length() > 60)
				listOfErrors.add("The length of the field [opname4] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 60");
		if(this.sexa != null)
			if(this.sexa.length() > 1)
				listOfErrors.add("The length of the field [sexa] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 1");
		if(this.sexs != null)
			if(this.sexs.length() > 1)
				listOfErrors.add("The length of the field [sexs] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 1");
		if(this.opstatus != null)
			if(this.opstatus.length() > 2)
				listOfErrors.add("The length of the field [opstatus] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 2");
		if(this.delmetod != null)
			if(this.delmetod.length() > 24)
				listOfErrors.add("The length of the field [delmetod] in the value object [ims.admin.vo.Opcs4Vo] is too big. It should be less or equal to 24");
		int errorCount = listOfErrors.size();
		if(errorCount == 0)
		{
			this.isBusy = false;
			this.isValidated = true;
			return null;
		}
		String[] result = new String[errorCount];
		for(int x = 0; x < errorCount; x++)
			result[x] = (String)listOfErrors.get(x);
		this.isBusy = false;
		this.isValidated = false;
		return result;
	}
	public void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		Opcs4Vo clone = new Opcs4Vo(this.id, this.version);
		
		clone.selindic = this.selindic;
		clone.opprefix = this.opprefix;
		clone.opcode = this.opcode;
		clone.opname3 = this.opname3;
		clone.opname4 = this.opname4;
		clone.sexa = this.sexa;
		clone.sexs = this.sexs;
		clone.opstatus = this.opstatus;
		clone.delmetod = this.delmetod;
		clone.isValidated = this.isValidated;
		
		this.isBusy = false;
		return clone;
	}
	public int compareTo(Object obj)
	{
		return compareTo(obj, true);
	}
	public int compareTo(Object obj, boolean caseInsensitive)
	{
		if (obj == null)
		{
			return -1;
		}
		if(caseInsensitive); // this is to avoid eclipse warning only.
		if (!(Opcs4Vo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A Opcs4Vo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		Opcs4Vo compareObj = (Opcs4Vo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getOpcode() == null && compareObj.getOpcode() != null)
				return -1;
			if(this.getOpcode() != null && compareObj.getOpcode() == null)
				return 1;
			if(this.getOpcode() != null && compareObj.getOpcode() != null)
			{
				if(caseInsensitive)
					retVal = this.getOpcode().toLowerCase().compareTo(compareObj.getOpcode().toLowerCase());
				else
					retVal = this.getOpcode().compareTo(compareObj.getOpcode());
			}
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.selindic != null)
			count++;
		if(this.opprefix != null)
			count++;
		if(this.opcode != null)
			count++;
		if(this.opname3 != null)
			count++;
		if(this.opname4 != null)
			count++;
		if(this.sexa != null)
			count++;
		if(this.sexs != null)
			count++;
		if(this.opstatus != null)
			count++;
		if(this.delmetod != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected String selindic;
	protected String opprefix;
	protected String opcode;
	protected String opname3;
	protected String opname4;
	protected String sexa;
	protected String sexs;
	protected String opstatus;
	protected String delmetod;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
