1 package com.atlassian.plugin.manager;
2
3 import com.atlassian.plugin.Plugin;
4 import com.atlassian.plugin.ModuleDescriptor;
5 import com.atlassian.plugin.PluginRestartState;
6
7 import java.util.Map;
8
9 /**
10 * Interface that represents a configuration state for plugins and plugin modules. The configuration state (enabled
11 * or disabled) is separate from the plugins and modules themselves because a plugin may have multiple
12 * states depending on the context.
13 * @since 2.2.0
14 * @author anatoli
15 *
16 */
17 public interface PluginPersistentState
18 {
19 /**
20 * Get the map of all states.
21 * @return The map that maps plugins and modules' keys to a state (Boolean.True/Boolean.False). State stored in this map represents only
22 * the <i>differences</i> between the current state and the default state configured in the plugin(module).
23 */
24 Map<String, Boolean> getMap();
25
26 /**
27 * Whether or not a plugin is enabled, calculated from it's current state AND default state.
28 */
29 boolean isEnabled(final Plugin plugin);
30
31 /**
32 * Whether or not a given plugin module is enabled in this state, calculated from it's current state AND default state.
33 */
34 boolean isEnabled(final ModuleDescriptor<?> pluginModule);
35
36 /**
37 * Get state map of the given plugin and its modules
38 * @param plugin
39 * @return The map that maps the plugin and its modules' keys to plugin state (Boolean.TRUE/Boolean.FALSE). State stored in this map represents only
40 * the <i>differences</i> between the current state and the default state configured in the plugin(module).
41 */
42 Map<String, Boolean> getPluginStateMap(final Plugin plugin);
43
44 /**
45 * Gets whether the plugin is expected to be upgraded, installed, or removed on next restart
46 *
47 * @param pluginKey The plugin to query
48 * @return The state of the plugin on restart
49 */
50 PluginRestartState getPluginRestartState(String pluginKey);
51 }