All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tinygroup.flow.config.Component Maven / Gradle / Ivy

/**
 *  Copyright (c) 1997-2013, tinygroup.org ([email protected]).
 *
 *  Licensed under the GPL, Version 3.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.gnu.org/licenses/gpl.html
 *
 *  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.
 * --------------------------------------------------------------------------
 *  版权 (c) 1997-2013, tinygroup.org ([email protected]).
 *
 *  本开源软件遵循 GPL 3.0 协议;
 *  如果您不遵循此协议,则不被允许使用此文件。
 *  你可以从下面的地址获取完整的协议文本
 *
 *       http://www.gnu.org/licenses/gpl.html
 */
package org.tinygroup.flow.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

/**
 * 组件接口
 * 
 * @author luoguo
 * 
 */
@XStreamAlias("component")
public class Component {
	/**
	 * className对应的类的属性配置
	 */
	private List properties;
	@XStreamAsAttribute
	private String name;
	@XStreamAsAttribute
	private String title;
	private String description;

	private transient Map propertyMap;

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Map getPropertyMap() {
		if (propertyMap == null) {
			propertyMap = new HashMap();
			for (FlowProperty property : getProperties()) {
				propertyMap.put(property.getName(), property);
			}
		}
		return propertyMap;
	}

	public List getProperties() {
		if (properties == null)
			properties = new ArrayList();
		return properties;
	}

	public void setProperties(List properties) {
		this.properties = properties;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void combile(Component component) {
		if (name == null) {
			name = component.getName();
		}
		if (title == null) {
			title = component.getTitle();
		}
		List parentProperties = component.getProperties();
		if (parentProperties != null) {
			if (properties == null) {
				properties = parentProperties;
			} else {
				for (FlowProperty pProperty : parentProperties) {
					FlowProperty myProperty = getPropertyMap().get(
							pProperty.getName());
					if (myProperty == null) {
						getPropertyMap().put(pProperty.getName(), pProperty);
					}
				}
			}
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy