java - Is it possible to use an enum inside a generic interface -
i have enum
public enum values{ value_1, value_2 }
i want define generic interface (maybe)
public interface listener<t extends enum<values>>{ public dosomething(object data); }
and subscriber like:
new subscriber implements listener<values.value_1>{ ...//do }
so can determine via reflection type used generic interface. have lot listeners , not want call every listerner, want determine type of message listening to.
how can achieve that? yeah know not work. can't possible... want suggestion how solve this.
you can reference types in generics eg: integer
, string
not values 1
or "string"
. same counts enums. can pass type of enum (in case values
) not direct value (value_1
)
so following valid case:
public interface listener<t extends enum<t>> { void dosomething(object data); }
Comments
Post a Comment