I am currently trying to translate a small application from java to kotlin without having to rewrite everything, however i am facing problems with a generic enum, since kotlin doesn't support generics in enums.
I have the following enum in java:
public enum Property {
LAST_VIEW(0, 1, Integer.class),
MAXIMIZED(2, false, Boolean.class),
private final int id;
private final String defaultValue;
private final Class<?> datatype;
<T> Property(final int id, final T defaultValue, final Class<T> datatype) {
this.id = id;
this.defaultValue = defaultValue == null ? null : defaultValue.toString();
this.datatype = datatype;
}
}
I am using this for a generic properties api in order to verify that my default values have the correct type and also do some runtime checks in order to give proper feedback as soon as i am making a mistake.
Is there anyways to make such a class in kotlin or should i consider refactoring my properties api instead?