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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -