/**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2020 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.holmes.common.api.stat;\r
\r
-import com.alibaba.fastjson.JSONObject;\r
+import com.google.gson.Gson;\r
import lombok.Getter;\r
import lombok.Setter;\r
\r
public static final byte EVENT_RAISED = 0;\r
\r
private static final long serialVersionUID = 4520003737132012000L;\r
- private final static Date clearedServerTime = null;\r
- private final Map<Integer, Integer> linkIdNodeIdxMap = new HashMap<Integer, Integer>();\r
+ private static final Date clearedServerTime = null;\r
+ private final Map<Integer, Integer> linkIdNodeIdxMap = new HashMap<>();\r
private byte eventType = EVENT_RAISED;\r
private long id = 0L;\r
private String alarmKey = "";\r
private boolean rootAlarmFlag = false;\r
private int linkId = -1;\r
private int nodeIdx = -1;\r
- private Set<Integer> linkIds = new HashSet<Integer>();\r
- private HashMap<String, Integer> priorityMap = new HashMap<String, Integer>();\r
- private HashMap<String, Integer> rootAlarmTypeMap = new HashMap<String, Integer>();\r
+ private Set<Integer> linkIds = new HashSet<>();\r
+ private HashMap<String, Integer> priorityMap = new HashMap<>();\r
+ private HashMap<String, Integer> rootAlarmTypeMap = new HashMap<>();\r
private int rootAlarmType = -1;\r
private boolean keyAlarmFlag = false;\r
private int keyAlarmType = -1;\r
linkIdNodeIdxMap.put(linkId, index);\r
}\r
\r
- /**\r
- * Comparison of the location of different links: 999 the same link: the location of the node\r
- * number less than otherIdIdx in the location of the number (in the otherIdIdx upstream):-1,\r
- * the same link: the node position number is equal to the number of position in the otherIdIdx\r
- * (in the same site otherIdIdx):0, the same link: the node location number is greater than the\r
- * number of locations in otherIdIdx (otherIdIdx) with the site):1,\r
- */\r
- public int CompareLinkPosition(Map<Integer, Integer> otherIdIdx) {\r
- Set<Integer> myIdSet = new HashSet<Integer>();\r
- myIdSet.addAll(this.linkIdNodeIdxMap.keySet());\r
- myIdSet.retainAll(otherIdIdx.keySet());\r
-\r
- if (myIdSet.isEmpty()) {\r
- return 999;\r
- }\r
-\r
- for (int tempLinkId : myIdSet) {\r
- return this.linkIdNodeIdxMap.get(tempLinkId) - otherIdIdx.get(tempLinkId);\r
- }\r
- return 999;\r
- }\r
-\r
public boolean containNode(int linkId, int index) {\r
return linkIdNodeIdxMap.containsKey(linkId) && linkIdNodeIdxMap.get(linkId) == index;\r
}\r
@Override\r
public String toString() {\r
\r
- return JSONObject.toJSONString(this);\r
+ return new Gson().toJson(this);\r
}\r
\r
@Override\r
\r
\r
public boolean containsPriority(String ruleId) {\r
- if (priorityMap.keySet().contains(ruleId)) {\r
- return true;\r
- }\r
- return false;\r
+ return priorityMap.keySet().contains(ruleId);\r
}\r
\r
public int getPriority(String ruleId) {\r
}\r
\r
public int getRootAlarmType(String ruleId) {\r
- Integer rootAlarmType = this.rootAlarmTypeMap.get(ruleId);\r
- if (rootAlarmType == null) {\r
- rootAlarmType = -1;\r
- }\r
- return rootAlarmType;\r
+ Integer rootAlarmTypeVar = this.rootAlarmTypeMap.get(ruleId);\r
+ return (rootAlarmTypeVar == null) ? -1 : rootAlarmTypeVar;\r
}\r
\r
}\r