/* * Copyright 2012 PRODYNA AG * * Licensed under the Eclipse Public License (EPL), Version 1.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.opensource.org/licenses/eclipse-1.0.php or * http://www.nabucco.org/License.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. */ package org.nabucco.testautomation.facade.message; import java.util.HashMap; import java.util.List; import java.util.Map; import org.nabucco.framework.base.facade.datatype.collection.NabuccoCollectionState; import org.nabucco.framework.base.facade.datatype.collection.NabuccoList; import org.nabucco.framework.base.facade.datatype.collection.NabuccoListImpl; import org.nabucco.framework.base.facade.datatype.property.NabuccoProperty; import org.nabucco.framework.base.facade.datatype.property.NabuccoPropertyContainer; import org.nabucco.framework.base.facade.datatype.property.NabuccoPropertyDescriptor; import org.nabucco.framework.base.facade.datatype.property.PropertyAssociationType; import org.nabucco.framework.base.facade.datatype.property.PropertyCache; import org.nabucco.framework.base.facade.datatype.property.PropertyDescriptorSupport; import org.nabucco.framework.base.facade.message.ServiceMessage; import org.nabucco.framework.base.facade.message.ServiceMessageSupport; import org.nabucco.testautomation.facade.datatype.property.base.Property; /** * PropertyListMsg<p/>Message containing a list of Properties<p/> * * @version 1.0 * @author Steffen Schmidt, PRODYNA AG, 2010-04-19 */ public class PropertyListMsg extends ServiceMessageSupport implements ServiceMessage { private static final long serialVersionUID = 1L; private static final String[] PROPERTY_CONSTRAINTS = { "m0,n;" }; public static final String PROPERTYLIST = "propertyList"; private NabuccoList<Property> propertyList; /** Constructs a new PropertyListMsg instance. */ public PropertyListMsg() { super(); } /** * CreatePropertyContainer. * * @return the NabuccoPropertyContainer. */ protected static NabuccoPropertyContainer createPropertyContainer() { Map<String, NabuccoPropertyDescriptor> propertyMap = new HashMap<String, NabuccoPropertyDescriptor>(); propertyMap.put(PROPERTYLIST, PropertyDescriptorSupport.createCollection(PROPERTYLIST, Property.class, 0, PROPERTY_CONSTRAINTS[0], false, PropertyAssociationType.COMPOSITION)); return new NabuccoPropertyContainer(propertyMap); } @Override public List<NabuccoProperty> getProperties() { List<NabuccoProperty> properties = super.getProperties(); properties.add(super.createProperty(PropertyListMsg.getPropertyDescriptor(PROPERTYLIST), this.propertyList)); return properties; } @Override @SuppressWarnings("unchecked") public boolean setProperty(NabuccoProperty property) { if (super.setProperty(property)) { return true; } if ((property.getName().equals(PROPERTYLIST) && (property.getType() == Property.class))) { this.propertyList = ((NabuccoList<Property>) property.getInstance()); return true; } return false; } @Override public boolean equals(Object obj) { if ((this == obj)) { return true; } if ((obj == null)) { return false; } if ((this.getClass() != obj.getClass())) { return false; } if ((!super.equals(obj))) { return false; } final PropertyListMsg other = ((PropertyListMsg) obj); if ((this.propertyList == null)) { if ((other.propertyList != null)) return false; } else if ((!this.propertyList.equals(other.propertyList))) return false; return true; } @Override public int hashCode() { final int PRIME = 31; int result = super.hashCode(); result = ((PRIME * result) + ((this.propertyList == null) ? 0 : this.propertyList .hashCode())); return result; } @Override public ServiceMessage cloneObject() { return this; } /** * Missing description at method getPropertyList. * * @return the NabuccoList<Property>. */ public NabuccoList<Property> getPropertyList() { if ((this.propertyList == null)) { this.propertyList = new NabuccoListImpl<Property>(NabuccoCollectionState.INITIALIZED); } return this.propertyList; } /** * Getter for the PropertyDescriptor. * * @param propertyName the String. * @return the NabuccoPropertyDescriptor. */ public static NabuccoPropertyDescriptor getPropertyDescriptor(String propertyName) { return PropertyCache.getInstance().retrieve(PropertyListMsg.class) .getProperty(propertyName); } /** * Getter for the PropertyDescriptorList. * * @return the List<NabuccoPropertyDescriptor>. */ public static List<NabuccoPropertyDescriptor> getPropertyDescriptorList() { return PropertyCache.getInstance().retrieve(PropertyListMsg.class).getAllProperties(); } }