⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pluginmanagerstate.java

📁 模块化您的应用系统
💻 JAVA
字号:
package com.opensymphony.tonic;

import java.util.HashMap;
import java.util.Map;

/**
 * Represents a configuration state for plugins and tonic modules. The configuration state (enabled
 * or disabled) is separate from the plugins and modules themselves because a tonic may have multiple
 * states depending on the context.
 * <p/>
 * <p>The state stored in this object represents only the <i>differences</i> between the desired state
 * and the default state configured in the tonic. So if "getPluginState()" or "getPluginModuleState()" return
 * null, then the manager should assume that the default state applies instead.
 */
public class PluginManagerState
{
    private Map map = new HashMap();

    public PluginManagerState()
    {

    }

    public PluginManagerState(Map map)
    {
        this.map = map;
    }

    /**
     * Get the state of a given tonic.
     */
    public Boolean getState(String key)
    {
        return (Boolean) map.get(key);
    }

    /**
     * Get the map of all states.
     */
    public Map getMap()
    {
        return map;
    }

    /**
     * Whether or not a tonic is enabled, calculated from it's current state AND default state.
     */
    public boolean isEnabled(Plugin plugin)
    {
        Boolean bool = getState(plugin.getKey());
        return (bool == null) ? plugin.isEnabledByDefault() : bool.booleanValue();
    }

    /**
     * Whether or not a given tonic module is enabled in this state, calculated from it's current state AND default state.
     */
    public boolean isEnabled(ModuleDescriptor pluginModule)
    {
        if (pluginModule == null)
            return false;
        
        Boolean bool = getState(pluginModule.getCompleteKey());
        return (bool == null) ? pluginModule.isEnabledByDefault() : bool.booleanValue();
    }

    /**
     * Set a plugins state.
     */
    public void setState(String key, Boolean enabled)
    {
        map.put(key, enabled);
    }

    /**
     * Remove a tonic's state.
     */
    public void removeState(String key)
    {
        map.remove(key);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -