Fix java check style issue
[msb/discovery.git] / sdclient / discovery-service / src / main / java / org / onap / msb / sdclient / wrapper / consul / model / ConsulResponse.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.wrapper.consul.model;
15
16 import java.math.BigInteger;
17
18 import com.google.common.base.Objects;
19
20 public class ConsulResponse<T> {
21
22     private final T response;
23     private final long lastContact;
24     private final boolean knownLeader;
25     private final BigInteger index;
26
27     public ConsulResponse(T response, long lastContact, boolean knownLeader, BigInteger index) {
28         this.response = response;
29         this.lastContact = lastContact;
30         this.knownLeader = knownLeader;
31         this.index = index;
32     }
33
34     public T getResponse() {
35         return response;
36     }
37
38     public long getLastContact() {
39         return lastContact;
40     }
41
42     public boolean isKnownLeader() {
43         return knownLeader;
44     }
45
46     public BigInteger getIndex() {
47         return index;
48     }
49
50     @Override
51     public String toString() {
52         return "ConsulResponse{" + "response=" + response + ", lastContact=" + lastContact + ", knownLeader="
53                         + knownLeader + ", index=" + index + '}';
54     }
55
56     @Override
57     public boolean equals(Object o) {
58         if (this == o)
59             return true;
60         if (o == null || getClass() != o.getClass())
61             return false;
62
63         ConsulResponse that = (ConsulResponse) o;
64
65         return Objects.equal(this.response, that.response) && Objects.equal(this.lastContact, that.lastContact)
66                         && Objects.equal(this.knownLeader, that.knownLeader) && Objects.equal(this.index, that.index);
67     }
68
69     @Override
70     public int hashCode() {
71         return Objects.hashCode(response, lastContact, knownLeader, index);
72     }
73 }