001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krad.datadictionary;
017
018 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
019
020 /**
021 * Common base for all objects that can be configured in the dictionary
022 *
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 */
025 public abstract class DictionaryBeanBase implements DictionaryBean {
026
027 private String namespaceCode;
028 private String componentCode;
029
030 public DictionaryBeanBase() {
031
032 }
033
034 /**
035 * @see DictionaryBean#getNamespaceCode()
036 */
037 @BeanTagAttribute(name = "namespaceCode")
038 public String getNamespaceCode() {
039 return namespaceCode;
040 }
041
042 /**
043 * Setter for the bean's associated namespace code
044 *
045 * @param namespaceCode
046 */
047 public void setNamespaceCode(String namespaceCode) {
048 this.namespaceCode = namespaceCode;
049 }
050
051 /**
052 * @see DictionaryBean#getComponentCode()
053 */
054 @BeanTagAttribute(name = "componentCode")
055 public String getComponentCode() {
056 return componentCode;
057 }
058
059 /**
060 * Setter for the bean's associated component code
061 *
062 * @param componentCode
063 */
064 public void setComponentCode(String componentCode) {
065 this.componentCode = componentCode;
066 }
067
068 /**
069 * Copies object by value
070 *
071 * @return copiedClass
072 */
073 public <T> T copy() {
074 T copiedClass = null;
075 try {
076 copiedClass = (T)this.getClass().newInstance();
077 }
078 catch(Exception exception) {
079 throw new RuntimeException();
080 }
081
082 copyProperties(copiedClass);
083
084 return copiedClass;
085 }
086
087 /**
088 * Copies properties for copy()
089 *
090 * @param dictionaryBeanBase base bean
091 */
092 protected <T> void copyProperties(T dictionaryBeanBase) {
093 DictionaryBeanBase dictionaryBeanBaseCopy = (DictionaryBeanBase) dictionaryBeanBase;
094 dictionaryBeanBaseCopy.setComponentCode(this.componentCode);
095 dictionaryBeanBaseCopy.setNamespaceCode(this.namespaceCode);
096 }
097 }