Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.EnumSet;

public class Main {
    public static void main(String... args) {
        System.out.println(ToolBar.NEW_WINDOW.getBtns());
        System.out.println(ToolBar.EDIT_WINDOW.getBtns());
        System.out.println(ToolBar.DELETE_WINDOW.getBtns());
    }
}

enum Action {
    SAVE, UPDATE, CANCEL, DELETE
}

enum ToolBar {
    NEW_WINDOW(EnumSet.of(Action.SAVE, Action.UPDATE)), EDIT_WINDOW(
            EnumSet.of(Action.UPDATE, Action.CANCEL)), DELETE_WINDOW(EnumSet.of(Action.CANCEL, Action.DELETE));

    private EnumSet<Action> buttons;

    ToolBar(EnumSet<Action> buttons) {
        this.buttons = buttons;
    }

    EnumSet<Action> getBtns() {
        return this.buttons;
    }
}