Let's say I have the following object
:
object CaseObjs {
trait Person
case object Female extends Person
case object Male extends Person
}
For purposes of Don't Repeat Yourself
, I'd like to use these CaseObjs.Male and .Female
as an Enum-like data structure in Java.
In other words, I'd like to use these case object
's in Java rather than create a new Java enum
that duplicates code.
Can I do this?