/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/nursing/vo/BladderManagement.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.nursing.vo;

/**
 * Linked to nursing.assessment.Bladder Management business object (ID: 1015100003).
 */
public class BladderManagement extends ims.nursing.assessment.vo.BladderManagementRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public BladderManagement()
	{
	}
	public BladderManagement(Integer id, int version)
	{
		super(id, version);
	}
	public BladderManagement(ims.nursing.vo.beans.BladderManagementBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.method = bean.getMethod() == null ? null : ims.nursing.vo.lookups.BladderManagementMethod.buildLookup(bean.getMethod());
		this.type = bean.getType() == null ? null : ims.nursing.vo.lookups.BladderManagementType.buildLookup(bean.getType());
		this.size = bean.getSize();
		this.dateinserted = bean.getDateInserted() == null ? null : bean.getDateInserted().buildDate();
		this.datenextchange = bean.getDateNextChange() == null ? null : bean.getDateNextChange().buildDate();
		this.iscurrentlyactive = bean.getIsCurrentlyActive();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.nursing.vo.beans.BladderManagementBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.method = bean.getMethod() == null ? null : ims.nursing.vo.lookups.BladderManagementMethod.buildLookup(bean.getMethod());
		this.type = bean.getType() == null ? null : ims.nursing.vo.lookups.BladderManagementType.buildLookup(bean.getType());
		this.size = bean.getSize();
		this.dateinserted = bean.getDateInserted() == null ? null : bean.getDateInserted().buildDate();
		this.datenextchange = bean.getDateNextChange() == null ? null : bean.getDateNextChange().buildDate();
		this.iscurrentlyactive = bean.getIsCurrentlyActive();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.nursing.vo.beans.BladderManagementBean bean = null;
		if(map != null)
			bean = (ims.nursing.vo.beans.BladderManagementBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.nursing.vo.beans.BladderManagementBean();
			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("METHOD"))
			return getMethod();
		if(fieldName.equals("TYPE"))
			return getType();
		if(fieldName.equals("SIZE"))
			return getSize();
		if(fieldName.equals("DATEINSERTED"))
			return getDateInserted();
		if(fieldName.equals("DATENEXTCHANGE"))
			return getDateNextChange();
		if(fieldName.equals("ISCURRENTLYACTIVE"))
			return getIsCurrentlyActive();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getMethodIsNotNull()
	{
		return this.method != null;
	}
	public ims.nursing.vo.lookups.BladderManagementMethod getMethod()
	{
		return this.method;
	}
	public void setMethod(ims.nursing.vo.lookups.BladderManagementMethod value)
	{
		this.isValidated = false;
		this.method = value;
	}
	public boolean getTypeIsNotNull()
	{
		return this.type != null;
	}
	public ims.nursing.vo.lookups.BladderManagementType getType()
	{
		return this.type;
	}
	public void setType(ims.nursing.vo.lookups.BladderManagementType value)
	{
		this.isValidated = false;
		this.type = value;
	}
	public boolean getSizeIsNotNull()
	{
		return this.size != null;
	}
	public Integer getSize()
	{
		return this.size;
	}
	public void setSize(Integer value)
	{
		this.isValidated = false;
		this.size = value;
	}
	public boolean getDateInsertedIsNotNull()
	{
		return this.dateinserted != null;
	}
	public ims.framework.utils.Date getDateInserted()
	{
		return this.dateinserted;
	}
	public void setDateInserted(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dateinserted = value;
	}
	public boolean getDateNextChangeIsNotNull()
	{
		return this.datenextchange != null;
	}
	public ims.framework.utils.Date getDateNextChange()
	{
		return this.datenextchange;
	}
	public void setDateNextChange(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.datenextchange = value;
	}
	public boolean getIsCurrentlyActiveIsNotNull()
	{
		return this.iscurrentlyactive != null;
	}
	public Boolean getIsCurrentlyActive()
	{
		return this.iscurrentlyactive;
	}
	public void setIsCurrentlyActive(Boolean value)
	{
		this.isValidated = false;
		this.iscurrentlyactive = 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.method == null)
			listOfErrors.add("Method is mandatory");
		if(this.type == null)
			listOfErrors.add("Type is mandatory");
		if(this.size == null)
			listOfErrors.add("Size is mandatory");
		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;
	
		BladderManagement clone = new BladderManagement(this.id, this.version);
		
		if(this.method == null)
			clone.method = null;
		else
			clone.method = (ims.nursing.vo.lookups.BladderManagementMethod)this.method.clone();
		if(this.type == null)
			clone.type = null;
		else
			clone.type = (ims.nursing.vo.lookups.BladderManagementType)this.type.clone();
		clone.size = this.size;
		if(this.dateinserted == null)
			clone.dateinserted = null;
		else
			clone.dateinserted = (ims.framework.utils.Date)this.dateinserted.clone();
		if(this.datenextchange == null)
			clone.datenextchange = null;
		else
			clone.datenextchange = (ims.framework.utils.Date)this.datenextchange.clone();
		clone.iscurrentlyactive = this.iscurrentlyactive;
		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 (!(BladderManagement.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A BladderManagement object cannot be compared an Object of type " + obj.getClass().getName());
		}
		BladderManagement compareObj = (BladderManagement)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getDateInserted() == null && compareObj.getDateInserted() != null)
				return -1;
			if(this.getDateInserted() != null && compareObj.getDateInserted() == null)
				return 1;
			if(this.getDateInserted() != null && compareObj.getDateInserted() != null)
				retVal = this.getDateInserted().compareTo(compareObj.getDateInserted());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.method != null)
			count++;
		if(this.type != null)
			count++;
		if(this.size != null)
			count++;
		if(this.dateinserted != null)
			count++;
		if(this.datenextchange != null)
			count++;
		if(this.iscurrentlyactive != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.nursing.vo.lookups.BladderManagementMethod method;
	protected ims.nursing.vo.lookups.BladderManagementType type;
	protected Integer size;
	protected ims.framework.utils.Date dateinserted;
	protected ims.framework.utils.Date datenextchange;
	protected Boolean iscurrentlyactive;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
