Path: blob/master/src/java.rmi/share/classes/sun/rmi/transport/ObjectEndpoint.java
41154 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package sun.rmi.transport;2526import java.rmi.server.ObjID;2728/**29* An object used as a key to the object table that maps an30* instance of this class to a Target.31*32* @author Ann Wollrath33**/34class ObjectEndpoint {3536private final ObjID id;37private final Transport transport;3839/**40* Constructs a new ObjectEndpoint instance with the specified id and41* transport. The specified id must be non-null, and the specified42* transport must either be non-null or the specified id must be43* equivalent to an ObjID constructed with ObjID.DGC_ID.44*45* @param id the object identifier46* @param transport the transport47* @throws NullPointerException if id is null48**/49ObjectEndpoint(ObjID id, Transport transport) {50if (id == null) {51throw new NullPointerException();52}53assert transport != null || id.equals(new ObjID(ObjID.DGC_ID));5455this.id = id;56this.transport = transport;57}5859/**60* Compares the specified object with this object endpoint for61* equality.62*63* This method returns true if and only if the specified object is an64* ObjectEndpoint instance with the same object identifier and65* transport as this object.66**/67public boolean equals(Object obj) {68if (obj instanceof ObjectEndpoint) {69ObjectEndpoint oe = (ObjectEndpoint) obj;70return id.equals(oe.id) && transport == oe.transport;71} else {72return false;73}74}7576/**77* Returns the hash code value for this object endpoint.78*/79public int hashCode() {80return id.hashCode() ^ (transport != null ? transport.hashCode() : 0);81}8283/**84* Returns a string representation for this object endpoint.85*/86public String toString() {87return id.toString();88}89}909192