Two dimensional enum

Are two dimensional enums a thing in java? i.e.:

public enum Modules {
    ATTACK(enum States{IDLE, NEAREST, NEARESTTOHQ;}),
    MOVE(enum States{IDLE, NORTH, SOUTH, EAST, WEST;}),
    SPAWN(enum States{IDLE, SIMPLESPAWN;});
}

Answer

I have a little trouble understanding what you are trying to do, but might this do it?

enum States {
    IDLE, NEAREST, NEARESTTOHQ,NORTH,SOUTH,EAST,WEST,IDLESPAWN
}

public enum Modules {
    ATTACK(IDLE, NEAREST, NEARESTTOHQ),
    MOVE(IDLE, NORTH, SOUTH, EAST, WEST),
    SPAWN(IDLE, SIMPLESPAWN);

    private States[] states;

    public Modules(States... states) {
        this.states=states;
    }
}

(Note that to get the syntax I used I believe you will need to put States in it’s own file and include an import States.* in Modules)

Leave a Reply

Your email address will not be published. Required fields are marked *