2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.model;
23 import java.io.Serializable;
24 import java.util.List;
25 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
28 public class PropertyDefinition extends PropertyDataDefinition
29 implements IOperationParameter, IComplexDefaultValue, Serializable {
32 /**The enumeration presents the list of property names with specific behavior
36 public enum PropertyNames {
38 MIN_INSTANCES("min_vf_module_instances", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL),
39 MAX_INSTANCES("max_vf_module_instances", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL),
40 INITIAL_COUNT("initial_count", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL),
41 VF_MODULE_LABEL("vf_module_label", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_RESOURCE_LEVEL),
42 VF_MODULE_DESCRIPTION("vf_module_description", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_RESOURCE_LEVEL),
43 NETWORK_ROLE("network_role", GroupInstancePropertyValueUpdateBehavior.NOT_RELEVANT),
44 AVAILABILTY_ZONE_COUNT("availability_zone_count", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL),
45 VFC_LIST("vfc_list", GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL);
47 private String propertyName;
48 private GroupInstancePropertyValueUpdateBehavior updateBehavior;
50 private PropertyNames(String propertyName,GroupInstancePropertyValueUpdateBehavior updateBehavior){
51 this.propertyName = propertyName;
52 this.updateBehavior = updateBehavior;
55 public String getPropertyName() {
59 public GroupInstancePropertyValueUpdateBehavior getUpdateBehavior() {
60 return updateBehavior;
63 * finds PropertyNames according received string name
67 public static PropertyNames findName(String name){
68 for (PropertyNames e : PropertyNames.values()) {
69 if (e.getPropertyName().equals(name)) {
77 * The enumeration presents the list of highest levels for which update property value is allowed
81 public enum GroupInstancePropertyValueUpdateBehavior{
82 NOT_RELEVANT("NOT_RELEVANT", -1),
83 UPDATABLE_ON_RESOURCE_LEVEL("UPDATABLE_ON_VF_LEVEL", 0),
84 UPDATABLE_ON_SERVICE_LEVEL("UPDATABLE_ON_SERVICE_LEVEL", 1);
89 private GroupInstancePropertyValueUpdateBehavior(String name, int levelNumber){
90 this.levelName = name;
91 this.levelNumber = levelNumber;
94 public String getLevelName() {
98 public int getLevelNumber() {
103 private static final long serialVersionUID = 188403656600317269L;
105 private List<PropertyConstraint> constraints;
106 // private Schema schema;
107 // private String status;
112 public PropertyDefinition() {
116 public PropertyDefinition(PropertyDataDefinition p) {
120 public PropertyDefinition(PropertyDefinition pd) {
122 this.setConstraints(pd.getConstraints());
123 //status = pd.status;
127 public List<PropertyConstraint> getConstraints() {
131 public void setConstraints(List<PropertyConstraint> constraints) {
132 this.constraints = constraints;
138 public String toString() {
139 return super.toString() + " [name=" + getName() + ", constraints="
140 + constraints + "]]";
143 // public void setSchema(Schema entrySchema) {
144 // this.schema = entrySchema;
148 // public Schema getSchema() {
152 // public String getStatus() {
156 // public void setStatus(String status) {
157 // this.status = status;
163 public boolean isDefinition() {
167 public void setDefinition(boolean definition) {
168 super.setDefinition(definition);
172 public int hashCode() {
173 final int prime = 31;
174 int result = super.hashCode();
175 result = prime * result + ((constraints == null) ? 0 : constraints.hashCode());
176 result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
177 //result = prime * result + ((status == null) ? 0 : status.hashCode());
182 public boolean equals(Object obj) {
185 if (!super.equals(obj))
187 if (getClass() != obj.getClass())
189 PropertyDefinition other = (PropertyDefinition) obj;
190 if (constraints == null) {
191 if (other.constraints != null)
193 } else if (!constraints.equals(other.constraints))
195 if (getName() == null) {
196 if (other.getName() != null)
198 } else if (!getName().equals(other.getName()))
200 // if (status == null) {
201 // if (other.status != null)
203 // } else if (!status.equals(other.status))