2 * Copyright 2016 ZTE, Inc. and others.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.msb.sdclient.wrapper.consul.model;
18 import com.google.common.base.Objects;
20 import java.math.BigInteger;
22 public class ConsulResponse<T> {
24 private final T response;
25 private final long lastContact;
26 private final boolean knownLeader;
27 private final BigInteger index;
29 public ConsulResponse(T response, long lastContact, boolean knownLeader, BigInteger index) {
30 this.response = response;
31 this.lastContact = lastContact;
32 this.knownLeader = knownLeader;
36 public T getResponse() {
40 public long getLastContact() {
44 public boolean isKnownLeader() {
48 public BigInteger getIndex() {
53 public String toString() {
54 return "ConsulResponse{" +
55 "response=" + response +
56 ", lastContact=" + lastContact +
57 ", knownLeader=" + knownLeader +
63 public boolean equals(Object o) {
64 if (this == o) return true;
65 if (o == null || getClass() != o.getClass()) return false;
67 ConsulResponse that = (ConsulResponse) o;
69 return Objects.equal(this.response, that.response) &&
70 Objects.equal(this.lastContact, that.lastContact) &&
71 Objects.equal(this.knownLeader, that.knownLeader) &&
72 Objects.equal(this.index, that.index);
76 public int hashCode() {
77 return Objects.hashCode(response, lastContact, knownLeader, index);