View Javadoc
1   package com.atlassian.plugin.event.events;
2   
3   import com.atlassian.annotations.PublicApi;
4   import com.atlassian.plugin.Plugin;
5   import com.atlassian.plugin.PluginState;
6   
7   import javax.annotation.Nonnull;
8   import java.util.Set;
9   
10  import static com.google.common.base.Preconditions.checkArgument;
11  import static com.google.common.base.Preconditions.checkNotNull;
12  
13  /**
14   * Event fired after dependent plugins have changed their state in response to a change in this plugin's state i.e.
15   * install, enable, uninstall, disable.
16   *
17   * @see com.atlassian.plugin.event.events
18   * @since 4.0.0
19   */
20  @PublicApi
21  public class PluginDependentsChangedEvent extends PluginEvent {
22      final PluginState state;
23      final Set<Plugin> disabled;
24      final Set<Plugin> cycled;
25  
26      public PluginDependentsChangedEvent(final Plugin plugin, @Nonnull final PluginState state, @Nonnull final Set<Plugin> disabled, @Nonnull final Set<Plugin> cycled) {
27          super(plugin);
28          this.state = checkNotNull(state);
29          checkArgument(state == PluginState.INSTALLED || state == PluginState.ENABLED || state == PluginState.UNINSTALLED || state == PluginState.DISABLED, "state must be one of INSTALLED, ENABLED, UNINSTALLED, DISABLED");
30          this.disabled = checkNotNull(disabled);
31          this.cycled = checkNotNull(cycled);
32      }
33  
34      /**
35       * End state of plugin that caused this event.
36       *
37       * @return one of {@link PluginState#INSTALLED}, {@link PluginState#ENABLED}, {@link PluginState#UNINSTALLED}, {@link PluginState#DISABLED}
38       */
39      public PluginState getState() {
40          return state;
41      }
42  
43      /**
44       * Plugins which had their state changed from enabled to disabled
45       *
46       * @return possibly empty set
47       */
48      public Set<Plugin> getDisabled() {
49          return disabled;
50      }
51  
52      /**
53       * Plugins which had their state changed from enabled to disabled to enabled
54       *
55       * @return possibly empty set
56       */
57      public Set<Plugin> getCycled() {
58          return cycled;
59      }
60  
61      @Override
62      public String toString() {
63          return super.toString() + ", disabled=" + disabled + ", cycled=" + cycled;
64      }
65  }