PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/hazelcast/src/main/java/com/hazelcast/impl/base/CallKey.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 62 lines | 38 code | 9 blank | 15 comment | 9 complexity | 1ba02b0c5d3138809918816da229a285 MD5 | raw file
 1/*
 2 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
 3 *
 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
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
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.
15 */
16
17package com.hazelcast.impl.base;
18
19import com.hazelcast.nio.Address;
20
21public class CallKey {
22    final Address callerAddress;
23    final int callerThreadId;
24
25    public CallKey(Address callerAddress, int callerThreadId) {
26        this.callerAddress = callerAddress;
27        this.callerThreadId = callerThreadId;
28    }
29
30    public Address getCallerAddress() {
31        return callerAddress;
32    }
33
34    public int getCallerThreadId() {
35        return callerThreadId;
36    }
37
38    @Override
39    public boolean equals(Object o) {
40        if (this == o) return true;
41        if (o == null || getClass() != o.getClass()) return false;
42        CallKey that = (CallKey) o;
43        if (callerThreadId != that.callerThreadId) return false;
44        if (!callerAddress.equals(that.callerAddress)) return false;
45        return true;
46    }
47
48    @Override
49    public int hashCode() {
50        int result = callerAddress.hashCode();
51        result = 31 * result + callerThreadId;
52        return result;
53    }
54
55    @Override
56    public String toString() {
57        return "CallKey{" +
58                "callerAddress=" + callerAddress +
59                ", callerThreadId=" + callerThreadId +
60                '}';
61    }
62}