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