/*
* Copyright 2002-2007 the original author or authors.
*
* 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 org.opentides.bean;
/**
* The system codes is test class required for unit test of code generation.
* The actual systemcodes used for implementation is found in core package
* of opentides.
*
*/
public class SystemCodes{
private String key;
private String value;
private String category;
private Long numberValue;
private Integer sortOrder;
private SystemCodes parent;
private String parentKey;
public SystemCodes() {
}
public SystemCodes(String key) {
setKey(key);
}
public SystemCodes(String category, String key, String value) {
setCategory(category);
setKey(key);
setValue(value);
}
public SystemCodes(String category, String key, String value,
boolean skipAudit) {
setCategory(category);
setKey(key);
setValue(value);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return key + ":" + value;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
*/
public void setKey(String key) {
this.key = key.trim().toUpperCase();
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value
* the value to set
*/
public void setValue(String value) {
this.value = value.trim();
}
/**
* @return the category
*/
public String getCategory() {
return category;
}
/**
* @param category
* the category to set
*/
public void setCategory(String category) {
this.category = category.trim().toUpperCase();
}
/**
* @return the sortOrder
*/
public final Integer getSortOrder() {
return sortOrder;
}
/**
* @param sortOrder
* the sortOrder to set
*/
public final void setSortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
}
/**
* @return the numberValue
*/
public synchronized Long getNumberValue() {
return this.numberValue;
}
/**
* @param numberValue
* the numberValue to set
*/
public synchronized void setNumberValue(Long numberValue) {
this.numberValue = numberValue;
}
/**
* @return the parent
*/
public SystemCodes getParent() {
return parent;
}
/**
* @param parent
* the parent to set
* @throws Exception
*/
public void setParent(SystemCodes parent) {
this.parent = parent;
}
@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((key == null) ? 0 : key.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final SystemCodes other = (SystemCodes) obj;
if (key == null) {
if (other.key != null)
return false;
} else if (!key.equals(other.key))
return false;
return true;
}
/**
* Check if the parents is null and not equal to itself.
*
* @param parent
* @return
*/
public boolean isParentValid() {
SystemCodes parent = this.getParent();
while (parent != null) {
if (this.key.equals(parent.getKey())) {
return false;
}
parent = parent.getParent();
}
return true;
}
public String getParentKey() {
if(this.parentKey == null) {
return "";
}
return this.parentKey;
}
public void setParentKey(String parentKey) {
this.parentKey = parentKey;
}
}