PortalRestApiCentralServiceImpl- Add null test before using nullable values
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / info / GroupDefinitionInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  * Modifications copyright (c) 2019 Nokia
20  * ================================================================================
21  */
22 package org.openecomp.sdc.be.info;
23
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import lombok.AccessLevel;
29 import lombok.Getter;
30 import lombok.Setter;
31 import org.openecomp.sdc.be.model.GroupDefinition;
32 import org.openecomp.sdc.be.model.GroupInstance;
33 import org.openecomp.sdc.be.model.GroupProperty;
34
35 @Getter
36 @Setter
37 public class GroupDefinitionInfo {
38
39     private String name;
40     private String description;
41     // the id is unique per group instance on graph.
42     private String uniqueId;
43     // the id is unique per group instance on graph.
44     private String groupInstanceUniqueId;
45     // the group UUID should be changed when one of the artifacts/component
46
47     // instances has been changed.
48     private String groupUUID;
49     // version should be changed when there is a change to the group's metadata
50
51     // or to the groups members
52
53     // (not necessarily when the VF version is changed). This field cannot be
54
55     // updated by user
56     private String version;
57     private String invariantUUID;
58     private String customizationUUID;
59     private Boolean isBase = null;
60     // artifacts - list of artifact uid. All artifacts in the group must already
61
62     // be uploaded to the VF
63     @Getter(AccessLevel.NONE)
64     @Setter(AccessLevel.NONE)
65     private List<ArtifactDefinitionInfo> artifacts;
66     private Map<String, String> members;
67     @Getter(AccessLevel.NONE)
68     @Setter(AccessLevel.NONE)
69     private List<? extends GroupProperty> properties;
70
71     public GroupDefinitionInfo(GroupDefinition other) {
72         this.setName(other.getName());
73         this.setDescription(other.getDescription());
74         this.setUniqueId(other.getUniqueId());
75         this.setVersion(other.getVersion());
76         this.setGroupUUID(other.getGroupUUID());
77         this.setInvariantUUID(other.getInvariantUUID());
78         this.setProperties(other.convertToGroupProperties());
79         if (other.getMembers() != null) {
80             this.members = new HashMap<>(other.getMembers());
81         }
82     }
83
84     public GroupDefinitionInfo(GroupInstance other) {
85         this.setName(other.getGroupName());
86         this.setDescription(other.getDescription());
87         this.setUniqueId(other.getGroupUid());
88         this.setGroupInstanceUniqueId(other.getUniqueId());
89         this.setVersion(other.getVersion());
90         this.setGroupUUID(other.getGroupUUID());
91         this.setCustomizationUUID(other.getCustomizationUUID());
92         this.setInvariantUUID(other.getInvariantUUID());
93         this.setProperties(other.convertToGroupInstancesProperties());
94     }
95
96     public List<ArtifactDefinitionInfo> getArtifacts() {
97         return (artifacts == null) ? null : new ArrayList<>(artifacts);
98     }
99
100     public void setArtifacts(List<ArtifactDefinitionInfo> artifacts) {
101         this.artifacts = (artifacts == null) ? null : new ArrayList<>(artifacts);
102     }
103
104     public List<GroupProperty> getProperties() {
105         return (properties == null) ? null : new ArrayList<>(properties);
106     }
107
108     public void setProperties(List<? extends GroupProperty> properties) {
109         this.properties = (properties == null) ? null : new ArrayList<>(properties);
110     }
111
112     @Override
113     public String toString() {
114         return "GroupDefinitionInfo [" + super.toString() + ", isBase=" + isBase + ", artifacts=" + artifacts + "]";
115     }
116 }