Elegant way to implement enum using case object
<p>I am trying to simulate enum behavior using case object.
It feels a little verbose, and not elegant, and I was wondering if there is a better way to achieve this.</p>

<p>So here is an example:</p>

<pre><code>sealed trait Operator
object Operator{
  def apply(value: String) = value match {
    case EqualsOp.name =&gt; EqualsOp
    case NotEqualOp.name =&gt; NotEqualOp
    case ContainsOp.name =&gt; ContainsOp
    case NotContainsOp.name =&gt; NotContainsOp
    case _ =&gt; UnknownOp
  }
}

case object EqualsOp extends Operator { val name = "equals" }
case object NotEqualOp extends Operator { val name = "not_equals" }
case object ContainsOp extends Operator { val name = "contains" }
case object NotContainsOp extends Operator { val name = "not_contains" }
</code></pre>

<p>Is there a better way to get this reverse mapping from a string to the actual case object?
Or in general better implement this?</p>