I have one enum, which implements an interface. The purpose of this interface is only to create a bound between multiples enums, so that I can later implements a plugin system. (This post may clear the thing a little bit.)
My library enum lloks like this :
public interface Resource extends Displayable<Resource> {
// all the methods that implements my enum
// Displayable is just an interface that I need in my game
// Just doesn't consider it, it can't interfer
}
And an exemple of an enum that implements this interface :
public enum LibraryEnum implements Resource {
// static final fields
// fields and resources
// all implemented methods
}
The thing is that I want to store this as an interface, to enable a sort of enum inheritance, because I'm about to create a plugin system. Any dev would just have to implements this unique interface to add resources in the game. But I don't know how he (or she) would name it (there might be some doubles).
I have a class with the associated field, as shown here :
@DatabaseTable(tableName = "packs")
public class Pack implements Displayable<Pack> {
@DatabaseField(columnName = "id", generatedId = true)
private Long packId;
// Here it is
@DatabaseField
private Resource resource;
// Is there any annotation arguments to add ?
@DatabaseField
private int quantity;
// Some other fiels
// Then constructors and methods
}
I've read the docs a little bit, and it say to create a custom implementation of the DataPersister interface. So I began to do it, but there is so many methods to implement (20?), that I don't know where to began and where to end. Maybe it's the wrong way to do it? The docs shows an exemple where are the methods aren't even there, and for the type that already exists in java (Date & DateTime).
How can I achieve this? Or is this even possible? If not, is there anyway to do what I want anyway (store unknown const enum fields in the database)?