479d6b855054f448fe93ade1b08f535286c8bc5f
[msb/discovery.git] / sdclient / discovery-service / src / main / java / org / onap / msb / sdclient / core / PublishFullAddress.java
1 /**
2  * Copyright 2016-2017 ZTE, Inc. and others.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.onap.msb.sdclient.core;
15
16 import java.io.Serializable;
17
18 import org.apache.commons.lang3.StringUtils;
19
20 import com.google.common.base.Objects;
21
22 import io.swagger.annotations.ApiModelProperty;
23
24 public class PublishFullAddress implements Serializable {
25     private static final long serialVersionUID = 1L;
26
27
28     @ApiModelProperty(value = "Service Publish IP")
29     private String ip;
30
31     @ApiModelProperty(value = "Service Publish Domain")
32     private String domain;
33
34     @ApiModelProperty(value = "Service Publish Port", required = true)
35     private String port;
36
37     @ApiModelProperty(value = "Service Publish URL,start with /", example = "/api/serviceName/v1", required = true)
38     private String publish_url;
39
40     @ApiModelProperty(value = "[visual Range]outSystem:0,inSystem:1", allowableValues = "0,1", example = "1",
41                     required = true)
42     private String visualRange;
43
44     @ApiModelProperty(value = "Service Publish Protocol", allowableValues = "http,https", example = "https",
45                     required = true)
46     private String publish_protocol;
47
48     public String getPublish_protocol() {
49         return publish_protocol;
50     }
51
52     public void setPublish_protocol(String publish_protocol) {
53         this.publish_protocol = publish_protocol;
54     }
55
56     public String getDomain() {
57         return domain;
58     }
59
60     public void setDomain(String domain) {
61         this.domain = domain;
62     }
63
64     public String getPublish_url() {
65         return publish_url;
66     }
67
68     public void setPublish_url(String publish_url) {
69         this.publish_url = publish_url;
70     }
71
72     public String getVisualRange() {
73         return visualRange;
74     }
75
76     public void setVisualRange(String visualRange) {
77         this.visualRange = visualRange;
78     }
79
80     public String getIp() {
81         return ip;
82     }
83
84     public void setIp(String ip) {
85         this.ip = ip;
86     }
87
88     public String getPort() {
89         return port;
90     }
91
92     public void setPort(String port) {
93         this.port = port;
94     }
95
96     public PublishFullAddress() {
97
98     }
99
100     public PublishFullAddress(String ip, String port, String publish_url, String visualRange, String publish_protocol) {
101         this.ip = ip;
102         this.port = port;
103         this.publish_url = publish_url;
104         this.visualRange = visualRange;
105         this.publish_protocol = publish_protocol;
106     }
107
108     @Override
109     public boolean equals(Object other) {
110         if (this == other)
111             return true;
112         if (other instanceof PublishFullAddress) {
113             PublishFullAddress that = (PublishFullAddress) other;
114             return Objects.equal(ip, that.ip) && Objects.equal(domain, that.domain) && Objects.equal(port, that.port)
115                             && Objects.equal(publish_url, that.publish_url)
116                             && Objects.equal(visualRange, that.visualRange)
117                             && Objects.equal(publish_protocol, that.publish_protocol);
118         } else {
119             return false;
120         }
121     }
122
123     @Override
124     public int hashCode() {
125         return Objects.hashCode(ip, domain, port, publish_url, visualRange, publish_protocol);
126     }
127
128     @Override
129     public String toString() {
130         // TODO Auto-generated method stub
131         if (StringUtils.isNotBlank(this.domain)) {
132             return (new StringBuilder().append(this.publish_protocol).append("://").append(this.domain).append(":")
133                             .append(this.port).append(this.publish_url)).toString();
134         } else {
135             return (new StringBuilder().append(this.publish_protocol).append("://").append(this.ip).append(":")
136                             .append(this.port).append(this.publish_url)).toString();
137         }
138
139     }
140
141
142 }