001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.cluster;
016    
017    import org.jgroups.Address;
018    
019    /**
020     * @author Shuyang Zhou
021     */
022    public class AddressImpl implements com.liferay.portal.kernel.cluster.Address {
023    
024            public AddressImpl(Address address) {
025                    _address = address;
026            }
027    
028            @Override
029            public boolean equals(Object obj) {
030                    if (obj == null) {
031                            return false;
032                    }
033    
034                    AddressImpl addressImpl = null;
035    
036                    try {
037                            addressImpl = (AddressImpl)obj;
038                    }
039                    catch (ClassCastException cce) {
040                            return false;
041                    }
042    
043                    if (_address.equals(addressImpl._address)) {
044                            return true;
045                    }
046                    else {
047                            return false;
048                    }
049            }
050    
051            public String getDescription() {
052                    return _address.toString();
053            }
054    
055            public Address getRealAddress() {
056                    return _address;
057            }
058    
059            @Override
060            public int hashCode() {
061                    return _address.hashCode();
062            }
063    
064            @Override
065            public String toString() {
066                    return _address.toString();
067            }
068    
069            private static final long serialVersionUID = 7969878022424426497L;
070    
071            private Address _address;
072    
073    }