2 * Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
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.
17 package org.openo.msb.wrapper.consul.model;
19 import com.google.common.base.Objects;
21 import java.math.BigInteger;
23 public class ConsulResponse<T> {
25 private final T response;
26 private final long lastContact;
27 private final boolean knownLeader;
28 private final BigInteger index;
30 public ConsulResponse(T response, long lastContact, boolean knownLeader, BigInteger index) {
31 this.response = response;
32 this.lastContact = lastContact;
33 this.knownLeader = knownLeader;
37 public T getResponse() {
41 public long getLastContact() {
45 public boolean isKnownLeader() {
49 public BigInteger getIndex() {
54 public String toString() {
55 return "ConsulResponse{" +
56 "response=" + response +
57 ", lastContact=" + lastContact +
58 ", knownLeader=" + knownLeader +
64 public boolean equals(Object o) {
65 if (this == o) return true;
66 if (o == null || getClass() != o.getClass()) return false;
68 ConsulResponse that = (ConsulResponse) o;
70 return Objects.equal(this.response, that.response) &&
71 Objects.equal(this.lastContact, that.lastContact) &&
72 Objects.equal(this.knownLeader, that.knownLeader) &&
73 Objects.equal(this.index, that.index);
77 public int hashCode() {
78 return Objects.hashCode(response, lastContact, knownLeader, index);