inherit from oparent
[msb/discovery.git] / sdclient / discovery-service / src / main / java / org / onap / msb / sdclient / core / NodeAddress.java
1 /**
2  * Copyright 2016 ZTE, Inc. and others.
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 package org.onap.msb.sdclient.core;
17
18 import io.swagger.annotations.ApiModelProperty;
19
20 import java.beans.PropertyChangeListener;
21 import java.beans.PropertyChangeSupport;
22 import java.io.Serializable;
23
24 import com.google.common.base.Objects;
25
26 public class NodeAddress implements Serializable {
27     private static final long serialVersionUID = 1L;
28
29     @ApiModelProperty(required = true)
30     private String ip;
31     
32     @ApiModelProperty(required = true)
33     private String port;
34     
35
36     
37     private PropertyChangeSupport changes = new PropertyChangeSupport(this);  
38     
39     public String getIp() {
40         return ip;
41     }
42
43     public void setIp(String ip) {
44         this.ip = ip;
45     }
46
47     public String getPort() {
48         return port;
49     }
50
51     public void setPort(String port) {
52         this.port = port;
53     }
54     
55     public NodeAddress(String ip,String port){
56         this.ip=ip;
57         this.port=port;
58     }
59     
60     public void setIPandPort(String ip,String port){
61         String oldAddress = this.ip+":"+this.port;
62         String newAddress = ip+":"+port;
63         this.ip=ip;
64         this.port=port;   
65         
66         changes.firePropertyChange("ip", oldAddress, newAddress);
67     }
68     
69     public void addPropertyChangeListener(PropertyChangeListener listener) {  
70         changes.addPropertyChangeListener(listener);  
71      }  
72     
73  public void removePropertyChangeListener(PropertyChangeListener listener) {  
74         changes.removePropertyChangeListener(listener);  
75      }  
76     
77     public NodeAddress(){
78        
79     }
80     
81     @Override
82     public boolean equals(Object other)
83     {
84         if(this == other)
85             return true;
86         if(other instanceof NodeAddress)
87         {
88             NodeAddress that = (NodeAddress)other;
89             return Objects.equal(ip, that.ip) && Objects.equal(port, that.port);
90         } else
91         {
92             return false;
93         }
94     }
95     
96     @Override
97     public int hashCode() {
98         return Objects.hashCode(ip, port);
99     }
100     
101     @Override
102     public String toString(){
103         return this.ip+":"+this.port;
104     }
105
106    
107     
108     
109    
110
111 }