62d21676f2cd29c90b0abba77e5879143ac25055
[sdc.git] /
1 /*
2  *
3  *  Copyright © 2017-2018 European Support Limited
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  * Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  */
18 package org.openecomp.sdc.versioning.types;
19
20 import java.util.Date;
21 import java.util.EnumMap;
22 import java.util.HashMap;
23 import java.util.Map;
24 import lombok.Getter;
25 import lombok.Setter;
26 import org.openecomp.sdc.versioning.dao.types.VersionStatus;
27
28 @Getter
29 @Setter
30 public class Item {
31
32     private String id;
33     private String type;
34     private String name;
35     private String owner;
36     private ItemStatus status;
37     private String description;
38     private Map<String, Object> properties = new HashMap<>();
39     private Map<VersionStatus, Integer> versionStatusCounters = new EnumMap<>(VersionStatus.class);
40     private Date creationTime;
41     private Date modificationTime;
42
43     public void addProperty(String key, Object value) {
44         properties.put(key, value);
45     }
46
47     public void addVersionStatus(VersionStatus versionStatus) {
48         Integer counter = versionStatusCounters.get(versionStatus);
49         versionStatusCounters.put(versionStatus, counter == null ? 1 : counter + 1);
50     }
51
52     public void removeVersionStatus(VersionStatus versionStatus) {
53         Integer counter = versionStatusCounters.get(versionStatus);
54         if (counter != null) {
55             if (counter == 1) {
56                 versionStatusCounters.remove(versionStatus);
57             } else {
58                 versionStatusCounters.put(versionStatus, counter - 1);
59             }
60         }
61     }
62 }