You are definitely right, you cannot override Enum#valueOf()
since it is a static method of Enum
class.
I don't think there is a naming convention. As you have already pointed out, there are few examples in Java:
I won't use getEnum
, since you are not getting the Enum
itself, but rather a value.
Using forName()
is not appropriate here, R
is not the name of the red color.
I would rather go with:
fromString()
since it is an opposite totoString()
;getColor()
for consistency with Java Standard Library.