I want to create an enum within an enum for sql query in java. For example I want to say table.create and it would return CREATE TABLE or database.create and it would return CREATE DATABASE. How can I do this?
enum SQL {
table("ALTER,CREATE"),
database("CREATE");
}
Why make it an enum within an enum?
Table.java
Database.java
With this example,
System.out.println(Table.CREATE);printsCREATE TABLE.This will also aid in readabilty becuase you can produce code like:
Which would be a bit easier to read and understand, IMO.
EDIT
To attempt to get close to what you’re after you could do something like:
Where you can call: