/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. package com.hazelcast.impl.base;
  17. import com.hazelcast.nio.Address;
  18. public class CallKey {
  19. final Address callerAddress;
  20. final int callerThreadId;
  21. public CallKey(Address callerAddress, int callerThreadId) {
  22. this.callerAddress = callerAddress;
  23. this.callerThreadId = callerThreadId;
  24. }
  25. public Address getCallerAddress() {
  26. return callerAddress;
  27. }
  28. public int getCallerThreadId() {
  29. return callerThreadId;
  30. }
  31. @Override
  32. public boolean equals(Object o) {
  33. if (this == o) return true;
  34. if (o == null || getClass() != o.getClass()) return false;
  35. CallKey that = (CallKey) o;
  36. if (callerThreadId != that.callerThreadId) return false;
  37. if (!callerAddress.equals(that.callerAddress)) return false;
  38. return true;
  39. }
  40. @Override
  41. public int hashCode() {
  42. int result = callerAddress.hashCode();
  43. result = 31 * result + callerThreadId;
  44. return result;
  45. }
  46. @Override
  47. public String toString() {
  48. return "CallKey{" +
  49. "callerAddress=" + callerAddress +
  50. ", callerThreadId=" + callerThreadId +
  51. '}';
  52. }
  53. }