update documentation
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / PolicyDefinition.java
1 package org.openecomp.sdc.be.model;
2
3 import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
4 import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner;
5 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
6
7 import java.io.Serializable;
8 import java.util.HashMap;
9 import java.util.Map;
10 import java.util.stream.Collectors;
11 /**
12  * public class representing the component policy
13  */
14 public class PolicyDefinition extends PolicyDataDefinition implements Serializable, PropertiesOwner {
15         /**
16          * 
17          */
18         private static final long serialVersionUID = 8433981810801300209L;
19         
20         /**
21          * public constructor by default
22          */
23         public PolicyDefinition() {
24                 super();
25         }
26
27         /**
28          * public constructor from superclass
29          * @param policy
30          */
31         public PolicyDefinition(Map<String, Object> policy) {
32                 super(policy);
33         }
34
35         /**
36          * public copy constructor
37          * @param other
38          */
39         public PolicyDefinition(PolicyDataDefinition other) {
40                 super(other);
41         }
42         
43         /**
44          * public converter constructor 
45          * builds PolicyDefinition object based on received PolicyTypeDefinition object
46          * @param policyType
47          */
48         public PolicyDefinition(PolicyTypeDefinition policyType) {
49                 this.setPolicyTypeName(policyType.getType());
50                 this.setPolicyTypeUid(policyType.getUniqueId());
51                 this.setDerivedFrom(policyType.getDerivedFrom());
52                 this.setDescription(policyType.getDescription());
53                 this.setVersion(policyType.getVersion());
54                 if (policyType.getProperties() != null) {
55                         this.setProperties(policyType.getProperties().stream().map(PropertyDataDefinition::new).collect(Collectors.toList()));
56                 }
57                 this.setTargets(new HashMap<>());
58
59         }
60
61         @Override
62         public String getNormalizedName() {
63                 return getName();
64         }
65 }