001    /**
002     * Copyright (c) 2000-2010 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.kernel.cluster;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.Validator;
019    
020    import java.io.Serializable;
021    
022    import java.net.InetAddress;
023    
024    /**
025     * @author Tina Tian
026     */
027    public class ClusterNode implements Serializable {
028    
029            public ClusterNode(String clusterNodeId) {
030                    _clusterNodeId = clusterNodeId;
031            }
032    
033            public boolean equals(Object obj) {
034                    if (this == obj) {
035                            return true;
036                    }
037    
038                    if (!(obj instanceof ClusterNode)) {
039                            return false;
040                    }
041    
042                    ClusterNode clusterNode = (ClusterNode)obj;
043    
044                    if (Validator.equals(_clusterNodeId, clusterNode._clusterNodeId)) {
045                            return true;
046                    }
047    
048                    return false;
049            }
050    
051            public String getClusterNodeId() {
052                    return _clusterNodeId;
053            }
054    
055            public String getHostName() {
056                    return _hostName;
057            }
058    
059            public InetAddress getInetAddress() {
060                    return _inetAddress;
061            }
062    
063            public int getPort() {
064                    return _port;
065            }
066    
067            public int hashCode() {
068                    return _clusterNodeId.hashCode();
069            }
070    
071            public void setHostName(String hostName) {
072                    _hostName = hostName;
073            }
074    
075            public void setInetAddress(InetAddress inetAddress) {
076                    _inetAddress = inetAddress;
077            }
078    
079            public void setPort(int port) {
080                    _port = port;
081            }
082    
083            public String toString() {
084                    StringBundler sb = new StringBundler(9);
085    
086                    sb.append("{clusterNodeId=");
087                    sb.append(_clusterNodeId);
088                    sb.append(", hostName=");
089                    sb.append(_hostName);
090                    sb.append(", inetAddress=");
091                    sb.append(_inetAddress);
092                    sb.append(", port=");
093                    sb.append(_port);
094                    sb.append("}");
095    
096                    return sb.toString();
097            }
098    
099            private String _clusterNodeId;
100            private String _hostName;
101            private InetAddress _inetAddress;
102            private int _port;
103    
104    }