com.giants.xmlmapping.XmlDataModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of giants-xmlmapping Show documentation
Show all versions of giants-xmlmapping Show documentation
Giants-xmlmapping Java Web Framework and reusable components.
The newest version!
/**
*
*/
package com.giants.xmlmapping;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections.MapUtils;
/**
* @author vencent.lu
*
*/
public class XmlDataModule implements Serializable {
private static final long serialVersionUID = 8384748949609831664L;
private Map dataObjectMap;
public T get() {
if (MapUtils.isEmpty(this.dataObjectMap)) {
return null;
}
return this.dataObjectMap.values().iterator().next();
}
public T get(Serializable id) {
if (this.dataObjectMap == null) {
return null;
}
return this.dataObjectMap.get(id);
}
public Collection getAll() {
if (this.dataObjectMap == null) {
return null;
}
return this.dataObjectMap.values();
}
public Boolean isNotEmpty() {
if (this.dataObjectMap == null) {
return false;
}
return MapUtils.isNotEmpty(this.dataObjectMap);
}
@SuppressWarnings("unchecked")
protected Object insert(Serializable id, Object object) {
if (this.dataObjectMap == null) {
this.dataObjectMap = new HashMap();
}
this.dataObjectMap.put(id, (T)object);
return object;
}
@SuppressWarnings("unchecked")
protected Object insert(Object object) {
if (this.dataObjectMap == null) {
this.dataObjectMap = new HashMap();
}
this.dataObjectMap.put(object.getClass(), (T)object);
return object;
}
protected void clear() {
this.dataObjectMap.clear();
}
}