I have a class that is intended to be used for **a future internal authentication library** ( I know there are already such existing libs ). So to make things **as simple as possible** to the developers using it **in many coming future projects** to make use of this library I had in mind them defining an enum with roles, simple example, the role sysadmin:

```
// Not a project specific class, but Auth is intended to be part of the library
class Auth {

        public static enum AUTH_ROLE {
            sysadmin( new Rule(AdminController.class, "*") );

            private String name;

            AUTH_ROLE() {
                name = this.name();
                Roles.add( name );
            }
            AUTH_ROLE(String name) {
                this.name = name;
                Roles.add( name );
            }

            AUTH_ROLE(Rule rule) {
                name = this.name();
                Roles.add( name, rule );
            }
            AUTH_ROLE(String name, Rule rule) {
                this.name = name;
                Roles.add( name, rule );
            }
            public String getName() {
                return name;
            }
        }

        public boolean hasRole(AUTH_ROLE role) {

            String[] usersRoles = getLoggedInUsersRoles();

            for ( String userRole : usersRoles ) {
                if ( role.getName().equals(userRole) )
                    return true;
            }

            return false;
        }

    }

```

Now, as you can see, the **enum AUTH\_ROLE** is **currently** \**defined*\* in what is **supposed** to be a **non project** specific class, **but the Auth class** is supposed to be part of the library that is to **be used by many projects**. 

The problem is that with the current design, I am forced to also define the **roles and their rules** in that same class, Auth, in order to define the method hasRole ( AUTH\_ROLE ...) ... 

What I would like to do, is to have this enum with all the current logic in it defined **ONCE** for **ALL PROJECTS** and allow for the developers in new projects to be able to **simply** just define the roles and their rules. 

The problem I believe exists, is that you cannot extend an enum in Java, so all that in the enum logic ( although simple, not the point! ) actually has to be repeated for each new project and possibly implement and interface provided in the library. 

If it were possible to extend, then a new enum would have been able to simply define those roles, that is : 

```
public enum AUTH_ROLE extends authlibrary.Auth.AUTH_ROLE {
    sysadmin( new Rule(AdminController.class, "*") );
} 

```

The **other option**, as I just mentioned, is to **define an interface** for the enum to implement, although as you can understand **we end up** with **an implementation for each new project**, be it as simple as copy and paste. 

I am not interested **in converting stuff to string or number** back and forth before calling the method and what not... 
This question is **not so much** about how **you can circumvent** \**the limitations*\* of the language, but merely to agree/accept that his is a limitation that would otherwise have resulted in cleaner code.

So, does anyone agree with that in this particular case, extending/including another enum would have been benefitial that would have resulted in less code?

Ps. I might be an idiot, so I want to reserve the right call myself an idiot :)