package pt.ist.renderers.model; import java.util.ArrayList; import java.util.List; /** * The MetaObjectCollection provides a wrapper for several meta objects. * It's purpose, besides behaving like a collection of objects or better a list, * is to coordinate the {@link #commit()} operation for all the meta objects * contained in this MetaObjectCollection. * * @author cfgi */ public class MetaObjectCollection extends MetaObject { private List metaObjects; public MetaObjectCollection() { super(); this.metaObjects = new ArrayList(); } public List getAllMetaObjects() { return this.metaObjects; } public void add(MetaObject metaObject) { this.metaObjects.add(metaObject); } public boolean remove(MetaObject metaObject) { return this.metaObjects.remove(metaObject); } public void setUser(UserIdentity user) { super.setUser(user); for (MetaObject metaObject : getAllMetaObjects()) { metaObject.setUser(user); } } public Object getObject() { List objects = new ArrayList(); for (MetaObject metaObject : getAllMetaObjects()) { objects.add(metaObject.getObject()); } return objects; } /** * @return ArrayList.class */ @Override public Class getType() { return ArrayList.class; } @Override public List getSlots() { List slots = new ArrayList(); for (MetaObject metaObject : getAllMetaObjects()) { slots.addAll(metaObject.getSlots()); } return slots; } @Override public void addSlot(MetaSlot slot) { } @Override public boolean removeSlot(MetaSlot slot) { return false; } @Override public MetaObjectKey getKey() { return null; } @Override public List getHiddenSlots() { List slots = new ArrayList(); for (MetaObject metaObject : getAllMetaObjects()) { slots.addAll(metaObject.getHiddenSlots()); } return slots; } @Override public void addHiddenSlot(MetaSlot slot) { } @Override public void commit() { for (MetaObject metaObject : getAllMetaObjects()) { metaObject.commit(); } } }