001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.kuali.rice.definition;
018:
019: import java.io.Serializable;
020: import java.util.ArrayList;
021: import java.util.Collection;
022: import java.util.HashMap;
023: import java.util.Iterator;
024: import java.util.List;
025: import java.util.Map;
026:
027: /**
028: * A marker interface for object definitions.
029: *
030: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
031: */
032: public class ObjectDefinition implements Serializable {
033:
034: private static final long serialVersionUID = 835423601196288352L;
035:
036: private String className;
037: private String messageEntity;
038: private boolean atRemotingLayer;
039: private final List constructorParameters = new ArrayList();
040: private final Map properties = new HashMap();
041:
042: public ObjectDefinition(Class objectClass) {
043: this (objectClass.getName());
044: }
045:
046: public ObjectDefinition(String className, String messageEntity) {
047: this .className = className;
048: this .messageEntity = messageEntity;
049: }
050:
051: public ObjectDefinition(String className) {
052: if (className == null) {
053: throw new IllegalArgumentException(
054: "Extension class name cannot be null");
055: }
056: this .className = className;
057: }
058:
059: public String getClassName() {
060: return this .className;
061: }
062:
063: public void addConstructorParameter(DataDefinition parameter) {
064: this .constructorParameters.add(parameter);
065: }
066:
067: public void removeConstructorParameter(DataDefinition parameter) {
068: this .constructorParameters.remove(parameter);
069: }
070:
071: public void setConstructorParameters(List parameters) {
072: this .constructorParameters.clear();
073: this .constructorParameters.addAll(parameters);
074: }
075:
076: public List getConstructorParameters() {
077: return this .constructorParameters;
078: }
079:
080: public void addProperty(PropertyDefinition property) {
081: if (property == null) {
082: return;
083: }
084: if (property.getName() == null) {
085: throw new IllegalArgumentException(
086: "PropertyDefinition cannot have a null name.");
087: }
088: this .properties.put(property.getName(), property);
089: }
090:
091: public PropertyDefinition getProperty(String name) {
092: return (PropertyDefinition) this .properties.get(name);
093: }
094:
095: public Collection getProperties() {
096: return this .properties.values();
097: }
098:
099: public void setProperties(Collection properties) {
100: this .properties.clear();
101: if (properties == null) {
102: return;
103: }
104: for (Iterator iterator = properties.iterator(); iterator
105: .hasNext();) {
106: addProperty((PropertyDefinition) iterator.next());
107: }
108: }
109:
110: public String getMessageEntity() {
111: return this .messageEntity;
112: }
113:
114: public void setMessageEntity(String messageEntity) {
115: this .messageEntity = messageEntity;
116: }
117:
118: public String toString() {
119: return "[ObjectDefinition: className: " + getClassName()
120: + ", messageEntity: " + getMessageEntity() + "]";
121: }
122:
123: public boolean isAtRemotingLayer() {
124: return this .atRemotingLayer;
125: }
126:
127: public void setAtRemotingLayer(boolean atRemotingLayer) {
128: this.atRemotingLayer = atRemotingLayer;
129: }
130: }
|