CODEARTS IDE-提取委托:重构后

时间:2024-04-16 15:05:24

重构后

class ExtractDelegate {
    private final Printer printer = new Printer();

    public static void main(String[] args) {
        new ExtractDelegate().print();
    }

    private void print() {
        printer.print();
    }

    public enum Printer {
        message("Hello World!");
        private String value;

        public String getValue() {
            return value;
        }

        Printer(String value) {
            this.value = value;
        }

        private void print() {
            System.out.println(message.getValue());
        }
    }
}
support.huaweicloud.com/usermanual-codeartside/codeartside_01_0133.html