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