/* * 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.schema.facade.message; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.nabucco.framework.base.facade.datatype.Description; import org.nabucco.framework.base.facade.datatype.Identifier; import org.nabucco.framework.base.facade.datatype.Key; import org.nabucco.framework.base.facade.datatype.Name; 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.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; /** * SchemaConfigSearchMsg<p/>Message for searching SchemaConfigs<p/> * * @version 1.0 * @author Steffen Schmidt, PRODYNA AG, 2010-04-09 */ public class SchemaConfigSearchMsg extends ServiceMessageSupport implements ServiceMessage { private static final long serialVersionUID = 1L; private static final String[] PROPERTY_CONSTRAINTS = { "l0,n;u0,n;m0,1;", "l0,255;u0,n;m0,1;", "l0,n;u0,n;m0,1;", "l0,255;u0,n;m0,1;" }; public static final String ID = "id"; public static final String NAME = "name"; public static final String SCHEMACONFIGKEY = "schemaConfigKey"; public static final String DESCRIPTION = "description"; private Identifier id; private Name name; private Key schemaConfigKey; private Description description; /** Constructs a new SchemaConfigSearchMsg instance. */ public SchemaConfigSearchMsg() { super(); this.initDefaults(); } /** InitDefaults. */ private void initDefaults() { } /** * CreatePropertyContainer. * * @return the NabuccoPropertyContainer. */ protected static NabuccoPropertyContainer createPropertyContainer() { Map<String, NabuccoPropertyDescriptor> propertyMap = new HashMap<String, NabuccoPropertyDescriptor>(); propertyMap.put(ID, PropertyDescriptorSupport.createBasetype(ID, Identifier.class, 0, PROPERTY_CONSTRAINTS[0], false)); propertyMap.put(NAME, PropertyDescriptorSupport.createBasetype(NAME, Name.class, 1, PROPERTY_CONSTRAINTS[1], false)); propertyMap .put(SCHEMACONFIGKEY, PropertyDescriptorSupport.createBasetype(SCHEMACONFIGKEY, Key.class, 2, PROPERTY_CONSTRAINTS[2], false)); propertyMap.put(DESCRIPTION, PropertyDescriptorSupport.createBasetype(DESCRIPTION, Description.class, 3, PROPERTY_CONSTRAINTS[3], false)); return new NabuccoPropertyContainer(propertyMap); } /** Init. */ public void init() { this.initDefaults(); } @Override public Set<NabuccoProperty> getProperties() { Set<NabuccoProperty> properties = super.getProperties(); properties.add(super.createProperty(SchemaConfigSearchMsg.getPropertyDescriptor(ID), this.id)); properties.add(super.createProperty(SchemaConfigSearchMsg.getPropertyDescriptor(NAME), this.name)); properties.add(super.createProperty(SchemaConfigSearchMsg.getPropertyDescriptor(SCHEMACONFIGKEY), this.schemaConfigKey)); properties .add(super.createProperty(SchemaConfigSearchMsg.getPropertyDescriptor(DESCRIPTION), this.description)); return properties; } @Override public boolean setProperty(NabuccoProperty property) { if (super.setProperty(property)) { return true; } if ((property.getName().equals(ID) && (property.getType() == Identifier.class))) { this.setId(((Identifier) property.getInstance())); return true; } else if ((property.getName().equals(NAME) && (property.getType() == Name.class))) { this.setName(((Name) property.getInstance())); return true; } else if ((property.getName().equals(SCHEMACONFIGKEY) && (property.getType() == Key.class))) { this.setSchemaConfigKey(((Key) property.getInstance())); return true; } else if ((property.getName().equals(DESCRIPTION) && (property.getType() == Description.class))) { this.setDescription(((Description) 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 SchemaConfigSearchMsg other = ((SchemaConfigSearchMsg) obj); if ((this.id == null)) { if ((other.id != null)) return false; } else if ((!this.id.equals(other.id))) return false; if ((this.name == null)) { if ((other.name != null)) return false; } else if ((!this.name.equals(other.name))) return false; if ((this.schemaConfigKey == null)) { if ((other.schemaConfigKey != null)) return false; } else if ((!this.schemaConfigKey.equals(other.schemaConfigKey))) return false; if ((this.description == null)) { if ((other.description != null)) return false; } else if ((!this.description.equals(other.description))) return false; return true; } @Override public int hashCode() { final int PRIME = 31; int result = super.hashCode(); result = ((PRIME * result) + ((this.id == null) ? 0 : this.id.hashCode())); result = ((PRIME * result) + ((this.name == null) ? 0 : this.name.hashCode())); result = ((PRIME * result) + ((this.schemaConfigKey == null) ? 0 : this.schemaConfigKey.hashCode())); result = ((PRIME * result) + ((this.description == null) ? 0 : this.description.hashCode())); return result; } @Override public ServiceMessage cloneObject() { return this; } /** * Missing description at method getId. * * @return the Identifier. */ public Identifier getId() { return this.id; } /** * Missing description at method setId. * * @param id the Identifier. */ public void setId(Identifier id) { this.id = id; } /** * Missing description at method getName. * * @return the Name. */ public Name getName() { return this.name; } /** * Missing description at method setName. * * @param name the Name. */ public void setName(Name name) { this.name = name; } /** * Missing description at method getSchemaConfigKey. * * @return the Key. */ public Key getSchemaConfigKey() { return this.schemaConfigKey; } /** * Missing description at method setSchemaConfigKey. * * @param schemaConfigKey the Key. */ public void setSchemaConfigKey(Key schemaConfigKey) { this.schemaConfigKey = schemaConfigKey; } /** * Missing description at method getDescription. * * @return the Description. */ public Description getDescription() { return this.description; } /** * Missing description at method setDescription. * * @param description the Description. */ public void setDescription(Description description) { this.description = description; } /** * Getter for the PropertyDescriptor. * * @param propertyName the String. * @return the NabuccoPropertyDescriptor. */ public static NabuccoPropertyDescriptor getPropertyDescriptor(String propertyName) { return PropertyCache.getInstance().retrieve(SchemaConfigSearchMsg.class).getProperty(propertyName); } /** * Getter for the PropertyDescriptorList. * * @return the List<NabuccoPropertyDescriptor>. */ public static List<NabuccoPropertyDescriptor> getPropertyDescriptorList() { return PropertyCache.getInstance().retrieve(SchemaConfigSearchMsg.class).getAllProperties(); } }