2 * Copyright 2016-2017 ZTE, Inc. and others.
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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
14 package org.onap.msb.sdclient.wrapper.consul.model;
16 import java.math.BigInteger;
18 import com.google.common.base.Objects;
20 public class ConsulResponse<T> {
22 private final T response;
23 private final long lastContact;
24 private final boolean knownLeader;
25 private final BigInteger index;
27 public ConsulResponse(T response, long lastContact, boolean knownLeader, BigInteger index) {
28 this.response = response;
29 this.lastContact = lastContact;
30 this.knownLeader = knownLeader;
34 public T getResponse() {
38 public long getLastContact() {
42 public boolean isKnownLeader() {
46 public BigInteger getIndex() {
51 public String toString() {
52 return "ConsulResponse{" + "response=" + response + ", lastContact=" + lastContact + ", knownLeader="
53 + knownLeader + ", index=" + index + '}';
57 public boolean equals(Object o) {
60 if (o == null || getClass() != o.getClass())
63 ConsulResponse that = (ConsulResponse) o;
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);
70 public int hashCode() {
71 return Objects.hashCode(response, lastContact, knownLeader, index);