##### Coverage Report - com.ctrip.apollo.model.ConfigChangeEvent

Classes in this File | Line Coverage | Branch Coverage | Complexity
ConfigChangeEvent |
100% | 8/8
N/A | N/A
| 1.0;1

1 |  |
     package com.ctrip.apollo.model;
2 |  |
3 |  |
     import java.util.Map;
4 |  |
     import java.util.Set;
5 |  |
6 |  |
     /**
7 |  |
      * A change event when a namespace's config is changed.
8 |  |
      * @author Jason Song(song_s@ctrip.com)
9 |  |
      */
10 |  |
     public class ConfigChangeEvent {
11 |  |
       private final String m_namespace;
12 |  |
       private final Map<String, ConfigChange> m_changes;
13 |  |
14 |  |
       /**
15 |  |
        * Constructor.
16 |  |
        * @param namespace the namespace of this change
17 |  |
        * @param changes the actual changes
18 |  |
        */
19 |  |
       public ConfigChangeEvent(String namespace,
20 | 5 |
                                Map<String, ConfigChange> changes) {
21 | 5 |
         m_namespace = namespace;
22 | 5 |
         m_changes = changes;
23 | 5 |
       }
24 |  |
25 |  |
       /**
26 |  |
        * Get the keys changed.
27 |  |
        * @return the list of the keys
28 |  |
        */
29 |  |
       public Set<String> changedKeys() {
30 | 3 |
         return m_changes.keySet();
31 |  |
       }
32 |  |
33 |  |
       /**
34 |  |
        * Get a specific change instance for the key specified.
35 |  |
        * @param key the changed key
36 |  |
        * @return the change instance
37 |  |
        */
38 |  |
       public ConfigChange getChange(String key) {
39 | 9 |
         return m_changes.get(key);
40 |  |
       }
41 |  |
42 |  |
       /**
43 |  |
        * Check whether the specified key is changed
44 |  |
        * @param key the key
45 |  |
        * @return true if the key is changed, false otherwise.
46 |  |
        */
47 |  |
       public boolean isChanged(String key) {
48 | 1 |
         return m_changes.containsKey(key);
49 |  |
       }
50 |  |
51 |  |
       /**
52 |  |
        * Get the namespace of this change event.
53 |  |
        * @return the namespace
54 |  |
        */
55 |  |
       public String getNamespace() {
56 | 2 |
         return m_namespace;
57 |  |
       }
58 |  |
     }