| 1 | package org.jtoolkit.essence.data; |
| 2 | |
| 3 | import org.jetbrains.annotations.NotNull; |
| 4 | import org.jtoolkit.essence.app.pojo.DataValue; |
| 5 | import org.jtoolkit.essence.concurrency.Immutable; |
| 6 | import org.jtoolkit.essence.data.impl.MetaData; |
| 7 | |
| 8 | import java.util.Collection; |
| 9 | import java.util.Map; |
| 10 | |
| 11 | /* |
| 12 | Copyright 2006 Peter Lawrey |
| 13 | |
| 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 15 | you may not use this file except in compliance with the License. |
| 16 | You may obtain a copy of the License at |
| 17 | |
| 18 | http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | |
| 20 | Unless required by applicable law or agreed to in writing, software |
| 21 | distributed under the License is distributed on an "AS IS" BASIS, |
| 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 23 | See the License for the specific language governing permissions and |
| 24 | limitations under the License. |
| 25 | */ |
| 26 | /** |
| 27 | * @author Peter Lawrey |
| 28 | */ |
| 29 | @Immutable |
| 30 | public class ClusterEvent extends DataValue implements Event { |
| 31 | private final String name; |
| 32 | private final Map<String, Collection<MetaData<Object,Object>>> changes; |
| 33 | |
| 34 | public ClusterEvent(@NotNull String name, @NotNull Map<String, Collection<MetaData<Object,Object>>> changes) { |
| 35 | this.name = name; |
| 36 | this.changes = changes; |
| 37 | } |
| 38 | |
| 39 | public void notifyListener(@NotNull Listener l) { |
| 40 | if (l instanceof Cluster.ClusterListener) { |
| 41 | ((Cluster.ClusterListener) l).onUpdate(name, changes); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | @NotNull public String getName() { |
| 46 | return name; |
| 47 | } |
| 48 | |
| 49 | @NotNull public Map<String, Collection<MetaData<Object,Object>>> getChanges() { |
| 50 | return changes; |
| 51 | } |
| 52 | } |