918ed6cc76991be228dad69e66dc7b011b078ee4
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / api / stat / VesAlarm.java
1 /*
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.common.api.stat;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.List;
22 import lombok.Getter;
23 import lombok.Setter;
24
25 @Getter
26 @Setter
27 public class VesAlarm implements Cloneable, Serializable{
28     private String domain;
29     private String eventId;
30     private String eventName;
31     private String eventType;
32     private Object internalHeaderFields;
33     private Long lastEpochMicrosec;
34     private String nfcNamingCode;
35     private String nfNamingCode;
36     private String priority;
37     private String reportingEntityId;
38     private String reportingEntityName;
39     private Integer sequence;
40     private String sourceId;
41     private String sourceName;
42     private Long startEpochMicrosec;
43     private Long version;
44
45     private List<AlarmAdditionalField> alarmAdditionalInformation;
46     private String alarmCondition;
47     private String alarmInterfaceA;
48     private String eventCategory;
49     private String eventSeverity;
50     private String eventSourceType;
51     private Long faultFieldsVersion;
52     private String specificProblem;
53     private String vfStatus;
54     private String parentId;
55
56     @Override
57     public int hashCode() {
58         return this.version.hashCode();
59     }
60
61     @Override
62     public boolean equals(Object object) {
63         if (object == null || !(object instanceof VesAlarm)) {
64             return false;
65         }
66         return this.version.equals(((VesAlarm) object).getVersion());
67     }
68
69     @Override
70     public Object clone() throws CloneNotSupportedException {
71         VesAlarm vesAlarm = new VesAlarm();
72
73         vesAlarm.setDomain(this.domain);
74         vesAlarm.setEventId(this.getEventId());
75         vesAlarm.setEventName(this.getEventName());
76         vesAlarm.setEventType(this.getEventType());
77         vesAlarm.setInternalHeaderFields(this.getInternalHeaderFields());
78         vesAlarm.setLastEpochMicrosec(this.getLastEpochMicrosec());
79         vesAlarm.setNfcNamingCode(this.nfcNamingCode);
80         vesAlarm.setNfNamingCode(this.getNfNamingCode());
81         vesAlarm.setPriority(this.getPriority());
82         vesAlarm.setReportingEntityId(this.getReportingEntityId());
83         vesAlarm.setReportingEntityName(this.reportingEntityName);
84         vesAlarm.setSequence(this.getSequence());
85         vesAlarm.setSourceId(this.getSourceId());
86         vesAlarm.setSourceName(this.getSourceName());
87         vesAlarm.setStartEpochMicrosec(this.getStartEpochMicrosec());
88         vesAlarm.setVersion(this.getVersion());
89
90         if (alarmAdditionalInformation != null) {
91             List<AlarmAdditionalField> alarmAdditionalFields = new ArrayList<>();
92             alarmAdditionalInformation.forEach(alarmAdditionalField -> {
93                 AlarmAdditionalField alarmAdditionalField1 = new AlarmAdditionalField();
94                 alarmAdditionalField1.setName(alarmAdditionalField.getName());
95                 alarmAdditionalField1.setName(alarmAdditionalField.getValue());
96                 alarmAdditionalFields.add(alarmAdditionalField1);
97             });
98             vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
99         }
100
101         vesAlarm.setAlarmCondition(this.getAlarmCondition());
102         vesAlarm.setAlarmInterfaceA(this.getAlarmInterfaceA());
103         vesAlarm.setEventCategory(this.getEventCategory());
104         vesAlarm.setEventSeverity(this.getEventSeverity());
105         vesAlarm.setEventSourceType(this.getEventSourceType());
106         vesAlarm.setFaultFieldsVersion(this.getFaultFieldsVersion());
107         vesAlarm.setSpecificProblem(this.getSpecificProblem());
108         vesAlarm.setVfStatus(this.vfStatus);
109
110         return vesAlarm;
111     }
112 }