Index: jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+>/**\n * Copyright (C) 2011 JTalks.org Team\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n */\npackage org.jtalks.common.model.entity;\n\nimport org.hibernate.validator.constraints.Length;\nimport org.hibernate.validator.constraints.NotBlank;\nimport org.jtalks.common.validation.annotations.UniqueConstraint;\nimport ru.javatalks.utils.general.Assert;\n\nimport javax.validation.constraints.NotNull;\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Represent jtalks engine component.\n *\n * @author Pavel Vervenko\n * @author Vahluev Vyacheslav\n */\npublic class Component extends Entity {\n private static final String COMPONENT_NAME_ILLEGAL_LENGTH = \"{component.name.length_constraint_violation}\";\n private static final String COMPONENT_DESCRIPTION_ILLEGAL_LENGTH = \"{component.description.length_constraint_violation}\";\n private static final String COMPONENT_EMPTY_COMPONENT_TYPE = \"{component.componentType.emptiness_constraint_violation}\";\n private static final String COMPONENT_CANT_BE_VOID = \"{component.name.emptiness_constraint_violation}\";\n\n public static final int COMPONENT_NAME_MAX_LENGTH = 100;\n public static final int COMPONENT_DESCRIPTION_MAX_LENGTH = 256;\n\n @NotBlank(message = COMPONENT_CANT_BE_VOID)\n @Length(max = COMPONENT_NAME_MAX_LENGTH, message = COMPONENT_NAME_ILLEGAL_LENGTH)\n private String name;\n\n @Length(max = COMPONENT_DESCRIPTION_MAX_LENGTH, message = COMPONENT_DESCRIPTION_ILLEGAL_LENGTH)\n private String description;\n\n @NotNull(message = COMPONENT_EMPTY_COMPONENT_TYPE)\n private ComponentType componentType;\n\n /**\n * Properties of the component\n */\n private List properties = new ArrayList();\n\n /**\n * Default constructor, sets nothing - all values are nulls.\n */\n public Component() {\n }\n\n /**\n * Constructor\n *\n * @param name name of the component\n * @param description description of the component\n * @param componentType type of the component {@see ComponentType}\n */\n public Component(String name, String description, ComponentType componentType) {\n this(name, description, componentType, new ArrayList());\n }\n\n /**\n * Constructor with all parameters\n *\n * @param name name of the component\n * @param description description of the component\n * @param componentType type of the component {@link ComponentType}\n * @param properties list of properties {@link Property}}\n */\n public Component(String name, String description, ComponentType componentType, List properties) {\n this.name = name;\n this.description = description;\n this.componentType = componentType;\n this.properties = properties;\n }\n\n /**\n * Get the component properties\n * @return properties\n */\n public List getProperties() {\n return properties;\n }\n\n /**\n * Set the component properties\n * @param properties to set\n */\n public void setProperties(List properties) {\n this.properties = properties;\n }\n\n /**\n * Get the component description.\n * @return description description of the component\n */\n public String getDescription() {\n return description;\n }\n\n /**\n * Set components description.\n * @param description new description of the component\n * @exception IllegalArgumentException if the description is null\n */\n public void setDescription(String description) {\n Assert.throwIfNull(description, \"description\");\n this.description = description;\n }\n\n /**\n * Get component's name.\n * @return name name of the component\n */\n public String getName() {\n return name;\n }\n\n /**\n * Set the name of the component.\n * @param name new name of the component\n * @exception IllegalArgumentException if the name is null\n */\n public void setName(String name) {\n Assert.throwIfNull(name, \"name\");\n this.name = name;\n }\n\n /**\n * Get the type of the component.\n * @return type type of the component\n */\n public ComponentType getComponentType() {\n return componentType;\n }\n\n /**\n * Set component's type.\n * @param type new type of the component\n */\n public void setComponentType(ComponentType type) {\n this.componentType = type;\n }\n\n /**\n * Adds the property to this component\n *\n * @param name is the name of the property\n * @param value is the value of the property\n */\n public void addProperty(String name, String value) {\n properties.add(new Property(name, value));\n }\n\n /**\n * Sets the property some value if one is exist. If it\n * is not, then adds a new property\n *\n * @param name is the name of the property\n * @param value is the value of the property\n */\n public void setProperty(String name, String value) {\n for (Property p : properties) {\n if (p.getName().equals(name)) {\n p.setValue(value);\n return;\n }\n }\n \n addProperty(name, value);\n }\n\n /**\n * Returns the property by its name or null\n * if none was found\n * @param name is the name of the property\n * @return property value or null if not found\n */\n public String getProperty(String name) {\n for (Property p : properties) {\n if (p.getName().equals(name)) {\n return p.getValue();\n }\n }\n return null;\n }\n\n /** {@inheritDoc} */\n @Override\n public String toString() {\n return \"Component [id=\" + getId() + \", name=\" + name + \", description=\" + description + \", componentType=\"\n + componentType + \"]\";\n }\n}\n =================================================================== --- jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java (revision dc648ec91dd5a9c895f077948ce552a65e5762cc) +++ jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java (revision ) @@ -60,7 +60,7 @@ } /** - * Constructor + * Constructor without properties * * @param name name of the component * @param description description of the component @@ -71,6 +71,17 @@ } /** + * Constructor without description + * + * @param name name of the component + * @param componentType type of the component {@see ComponentType} + * @param properties list of properties {@link Property}} + */ + public Component(String name, ComponentType componentType, List properties) { + this(name, new String(), componentType, properties); + } + + /** * Constructor with all parameters * * @param name name of the component @@ -112,10 +123,8 @@ /** * Set components description. * @param description new description of the component - * @exception IllegalArgumentException if the description is null */ public void setDescription(String description) { - Assert.throwIfNull(description, "description"); this.description = description; }