I write a library that should rely on enums but the actual enum should be defined by the user of my library.
In the following example the authorize method requires parameters of the enum type Permission.
acl.authorize(userX, Permission.READ, Permission.WRITE)
My library should be able to handle arbitrary permissions defined by the library user. But I cannot compile my library without a Permission enum. So I would need something like
abstract enum Permission
in my library. Is there a workaround to do this?
I would use an interface which the enum would then implement. Something along the lines of
which would be used by e.g. the client to define an enum such as
Then your API would accept parameters using the
PermissionTypetype