inherit from oparent
[msb/discovery.git] / sdclient / discovery-service / src / main / java / org / onap / msb / sdclient / core / PublishFullAddress.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.io.Serializable;
21
22 import org.apache.commons.lang3.StringUtils;
23 import org.onap.msb.sdclient.wrapper.consul.model.health.ServiceHealth;
24
25 import com.google.common.base.Objects;
26
27 public class PublishFullAddress implements Serializable {
28   private static final long serialVersionUID = 1L;
29
30
31   @ApiModelProperty(value = "Service Publish IP")
32   private String ip;  
33
34   @ApiModelProperty(value = "Service Publish Domain")
35   private String domain;
36   
37   @ApiModelProperty(value = "Service Publish Port", required = true)
38   private String port;
39   
40   @ApiModelProperty(value = "Service Publish URL,start with /",example = "/api/serviceName/v1", required = true)
41   private String publish_url;
42   
43   @ApiModelProperty(value = "[visual Range]outSystem:0,inSystem:1", allowableValues = "0,1", example = "1", required = true)
44   private String visualRange;
45   
46   @ApiModelProperty(value = "Service Publish Protocol",allowableValues = "http,https",example = "https", required = true)
47   private String publish_protocol;
48
49   public String getPublish_protocol() {
50     return publish_protocol;
51   }
52
53   public void setPublish_protocol(String publish_protocol) {
54     this.publish_protocol = publish_protocol;
55   }
56
57   public String getDomain() {
58     return domain;
59   }
60
61   public void setDomain(String domain) {
62     this.domain = domain;
63   }
64
65   public String getPublish_url() {
66     return publish_url;
67   }
68
69   public void setPublish_url(String publish_url) {
70     this.publish_url = publish_url;
71   }
72
73   public String getVisualRange() {
74     return visualRange;
75   }
76
77   public void setVisualRange(String visualRange) {
78     this.visualRange = visualRange;
79   }
80
81   public String getIp() {
82       return ip;
83   }
84
85   public void setIp(String ip) {
86       this.ip = ip;
87   }
88
89   public String getPort() {
90       return port;
91   }
92
93   public void setPort(String port) {
94       this.port = port;
95   }
96   
97   public PublishFullAddress(){
98     
99   }
100   
101   public PublishFullAddress(String ip,String port,String publish_url,String visualRange,String publish_protocol ){
102     this.ip=ip;
103     this.port=port;
104     this.publish_url=publish_url;
105     this.visualRange=visualRange;
106     this.publish_protocol=publish_protocol;
107   }
108   
109   @Override
110   public boolean equals(Object other)
111   {
112       if(this == other)
113           return true;
114       if(other instanceof PublishFullAddress)
115       {
116         PublishFullAddress that = (PublishFullAddress)other;
117           return Objects.equal(ip, that.ip) 
118                  && Objects.equal(domain, that.domain)
119                  && Objects.equal(port, that.port)
120                  && Objects.equal(publish_url, that.publish_url)
121                  && Objects.equal(visualRange, that.visualRange)
122                  && Objects.equal(publish_protocol, that.publish_protocol);
123       } else
124       {
125           return false;
126       }
127   }
128   
129   @Override
130   public int hashCode() {
131       return Objects.hashCode(ip, domain,port,publish_url,visualRange,publish_protocol);
132   }
133   
134   @Override
135   public String toString() {
136     // TODO Auto-generated method stub
137     if(StringUtils.isNotBlank(this.domain)){
138       return (new StringBuilder().append(this.publish_protocol).append("://").append(this.domain).append(":").append(this.port).append(this.publish_url)).toString();
139     }
140     else {
141       return (new StringBuilder().append(this.publish_protocol).append("://").append(this.ip).append(":").append(this.port).append(this.publish_url)).toString();
142     }
143
144   }
145   
146
147 }