View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    * 
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package net.jini.lookup;
20  
21  import net.jini.core.lookup.ServiceRegistrar;
22  
23  /**
24   * A wrapper class for a ServiceRegistrar.
25   */
26  final class ProxyReg {
27      private final ServiceRegistrar proxy;
28      private final int hash;
29  
30      public ProxyReg(ServiceRegistrar proxy) {
31  	if (proxy == null) {
32  	    throw new IllegalArgumentException("proxy cannot be null");
33  	}
34  	this.proxy = proxy;
35  	hash = proxy.hashCode();
36      } //end constructor
37  
38      @Override
39      public boolean equals(Object obj) {
40  	if (obj instanceof ProxyReg) {
41  	    return getProxy().equals(((ProxyReg) obj).getProxy());
42  	} else {
43  	    return false;
44  	}
45      } //end equals
46  
47      @Override
48      public int hashCode() {
49  	return hash;
50      } //end hashCode
51  
52      /**
53       * @return the proxy
54       */
55      public ServiceRegistrar getProxy() {
56  	return proxy;
57      }
58      
59  } //end class ServiceDiscoveryManager.ProxyReg