Eclipse自动单例生成器

时间:2018-07-11 10:32:31

标签: java eclipse performance syntax singleton

eclipse是否具有在创建新类时自动生成该类的单例的功能?

就像实现在“创建新类”对话框中定义的主类的抽象方法一样,您是否可以做到这样创建一个类呢?

package org.desk.game.model.player.skill;


public final class SkillConfig {

    /**
     * The singleton.
     */
    private static final SkillConfig skillConfig = new SkillConfig();

    /**
     * Get the singleton instance of this class.
     * 
     * @return the singleton.
     */
    public static SkillConfig getInstance() {
        return skillConfig;
    }

    /**
     * Default private constructor to prevent instantiation by other classes.
     */
    private SkillConfig() {

    }
}

0 个答案:

没有答案