Added some tools for engine instance management
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / engine / entity / EngineEntity.java
1 /**
2  * Copyright 2020 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.engine.entity;
18
19 public class EngineEntity {
20     private String ip;
21     private int port;
22     private long lastModified;
23
24     public EngineEntity(String ip, int port) {
25         this.ip = ip;
26         this.port = port;
27         this.lastModified = System.currentTimeMillis();
28     }
29
30     public EngineEntity() {
31     }
32
33     public String getId() {
34         return ip + "_" + port;
35     }
36
37     public String getIp() {
38         return ip;
39     }
40
41     public void setIp(String ip) {
42         this.ip = ip;
43     }
44
45     public int getPort() {
46         return port;
47     }
48
49     public void setPort(int port) {
50         this.port = port;
51     }
52
53     public long getLastModified() {
54         return lastModified;
55     }
56
57     public void setLastModified(long lastModified) {
58         this.lastModified = lastModified;
59     }
60
61     @Override
62     public boolean equals(Object o) {
63         if (o == null || ! (o instanceof  EngineEntity)) {
64             return false;
65         }
66
67         return ((EngineEntity) o).getId().equals(getId());
68     }
69
70     @Override
71     public int hashCode() {
72         return getId().hashCode();
73     }
74 }