blob: 3ac97f11e6f852b8c9af6566ad3c3bc5115dc285 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
package Ice;
/**
* This class wraps a proxy to allow it to be used the key for a hashed collection.
* The <code>hashCode</code> and <code>equals</code> methods are based on the object identity and
* the facet of the proxy.
*
* @see ProxyIdentityAndFacetCompare
* @see ProxyIdentityCompare
* @see ProxyIdentityKey
*
**/
public class ProxyIdentityFacetKey
{
/**
* Initializes this class with the passed proxy.
*
* @param proxy The proxy for this instance.
**/
public
ProxyIdentityFacetKey(Ice.ObjectPrx proxy)
{
_proxy = proxy;
//
// Cache the identity and facet, and compute the hash code.
//
_identity = proxy.ice_getIdentity();
_facet = proxy.ice_getFacet();
int h = 5381;
h = IceInternal.HashUtil.hashAdd(h, _identity);
h = IceInternal.HashUtil.hashAdd(h, _facet);
_hashCode = h;
}
/**
* Computes a hash value based on the object identity and the facet of the proxy.
*
* @return The hash value.
**/
public int
hashCode()
{
return _hashCode;
}
/**
* Compares this proxy with the passed object for equality.
*
* @param obj The object to compare this proxy with.
* @return <code>true</code> if the passed object is a proxy with the same object
* identity and facet as this proxy; <code>false</code>, otherwise.
**/
public boolean
equals(java.lang.Object obj)
{
if(this == obj)
{
return true;
}
if(obj instanceof ProxyIdentityFacetKey)
{
ProxyIdentityFacetKey other = (ProxyIdentityFacetKey)obj;
return (_hashCode == other._hashCode) && _identity.equals(other._identity) && _facet.equals(other._facet);
}
return false;
}
/**
* Returns the proxy stored by this class.
*
* @return The proxy stored by this class.
**/
public Ice.ObjectPrx
getProxy()
{
return _proxy;
}
final private Ice.ObjectPrx _proxy;
final private Ice.Identity _identity;
final private String _facet;
final private int _hashCode;
}
|