How can I eliminate duplicated Enum code?

后端 未结 15 898
眼角桃花
眼角桃花 2020-12-24 13:40

I have a large number of Enums that implement this interface:

/**
 * Interface for an enumeration, each element of which can be uniquely identified by its co         


        
15条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 13:59

    In your specific case, the getCode() / getByCode(String code) methods seems very closed (euphemistically speaking) to the behaviour of the toString() / valueOf(String value) methods provided by all enumeration. Why don't you want to use them?

提交回复
热议问题