decoratableobject.java

来自「Python Development Environment (Python I」· Java 代码 · 共 49 行

JAVA
49
字号
package org.python.pydev.core.structure;

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

/**
 * This is a class that can be 'decoratable' with additional information
 */
public class DecoratableObject {
    /**
     * This is used so that specific refactoring engines can add information regarding its specifics in
     * the request.
     */
    private Map<String, Object> additionalRefactoringInfo;
    
    /**
     * Only initialize on request
     */
    private Map<String, Object> getAdditionalRefactoringInfo() {
        if(additionalRefactoringInfo == null){
            additionalRefactoringInfo = new HashMap<String, Object>();
        }
        return additionalRefactoringInfo;
    }

    /**
     * @param key this is the key for which we have some additional value relative to the
     * refactoring request using it
     * @param defaultValue this is the default value that should be returned if there
     * is currently no value for the given key
     * @return the additional info (if available) or the default specified
     */
    public Object getAdditionalInfo(String key, Object defaultValue){
        Object val = this.getAdditionalRefactoringInfo().get(key);
        if(val == null){
            return defaultValue;
        }
        return val;
    }
    
    /**
     * Set some value for some additional info for this request.
     */
    public void setAdditionalInfo(String key, Object value){
        this.getAdditionalRefactoringInfo().put(key, value);
    }

}

⌨️ 快捷键说明

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