001    /**
002     * Copyright (c) 2000-present 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 java.io.Serializable;
018    
019    import java.util.Arrays;
020    import java.util.Collections;
021    import java.util.List;
022    
023    /**
024     * @author Tina Tian
025     */
026    public class ClusterEvent implements Serializable {
027    
028            public static ClusterEvent depart(ClusterNode... clusterNodes) {
029                    return new ClusterEvent(
030                            ClusterEventType.DEPART, Arrays.asList(clusterNodes));
031            }
032    
033            public static ClusterEvent depart(List<ClusterNode> clusterNodes) {
034                    return new ClusterEvent(ClusterEventType.DEPART, clusterNodes);
035            }
036    
037            public static ClusterEvent join(ClusterNode... clusterNodes) {
038                    return new ClusterEvent(
039                            ClusterEventType.JOIN, Arrays.asList(clusterNodes));
040            }
041    
042            public static ClusterEvent join(List<ClusterNode> clusterNodes) {
043                    return new ClusterEvent(ClusterEventType.JOIN, clusterNodes);
044            }
045    
046            public ClusterEvent(ClusterEventType clusterEventType) {
047                    this(clusterEventType, Collections.<ClusterNode>emptyList());
048            }
049    
050            public ClusterEvent(
051                    ClusterEventType clusterEventType, List<ClusterNode> clusterNodes) {
052    
053                    _clusterEventType = clusterEventType;
054                    _clusterNodes = clusterNodes;
055            }
056    
057            public ClusterEventType getClusterEventType() {
058                    return _clusterEventType;
059            }
060    
061            public List<ClusterNode> getClusterNodes() {
062                    return _clusterNodes;
063            }
064    
065            private final ClusterEventType _clusterEventType;
066            private final List<ClusterNode> _clusterNodes;
067    
068    }