001    /**
002     * Copyright (c) 2000-2011 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            @Override
034            public boolean equals(Object obj) {
035                    if (this == obj) {
036                            return true;
037                    }
038    
039                    if (!(obj instanceof ClusterNode)) {
040                            return false;
041                    }
042    
043                    ClusterNode clusterNode = (ClusterNode)obj;
044    
045                    if (Validator.equals(_clusterNodeId, clusterNode._clusterNodeId)) {
046                            return true;
047                    }
048    
049                    return false;
050            }
051    
052            public String getClusterNodeId() {
053                    return _clusterNodeId;
054            }
055    
056            public String getHostName() {
057                    return _hostName;
058            }
059    
060            public InetAddress getInetAddress() {
061                    return _inetAddress;
062            }
063    
064            public int getPort() {
065                    return _port;
066            }
067    
068            @Override
069            public int hashCode() {
070                    return _clusterNodeId.hashCode();
071            }
072    
073            public void setHostName(String hostName) {
074                    _hostName = hostName;
075            }
076    
077            public void setInetAddress(InetAddress inetAddress) {
078                    _inetAddress = inetAddress;
079            }
080    
081            public void setPort(int port) {
082                    _port = port;
083            }
084    
085            @Override
086            public String toString() {
087                    StringBundler sb = new StringBundler(9);
088    
089                    sb.append("{clusterNodeId=");
090                    sb.append(_clusterNodeId);
091                    sb.append(", hostName=");
092                    sb.append(_hostName);
093                    sb.append(", inetAddress=");
094                    sb.append(_inetAddress);
095                    sb.append(", port=");
096                    sb.append(_port);
097                    sb.append("}");
098    
099                    return sb.toString();
100            }
101    
102            private String _clusterNodeId;
103            private String _hostName;
104            private InetAddress _inetAddress;
105            private int _port;
106    
107    }