Advertisement
TheReturningVoid

Untitled

Sep 17th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.70 KB | None | 0 0
  1. object SampleEnum extends Enumeration {
  2.   val SAMPLE = SampleEnum("sample")
  3.   val SAMPLE2 = SampleEnum(SAMPLE, "sample2")
  4.  
  5.   class SSampleEnum(val path: String) extends Val(nextId, path)
  6.   class PSSampleEnum(parent: SSampleEnum, override val path: String) extends SSampleEnum(parent.path + "." + path)
  7.   def apply(path: String): SSampleEnum = new SSampleEnum(path)
  8.   def apple(parent: SSampleEnum, path: String): PSSampleEnum = new PSSampleEnum(parent, path)
  9. }
  10.  
  11. scala> SampleEnum.SAMPLE
  12. res0: Sample.SSampleEnum = sample
  13.  
  14. scala> SampleEnum.SAMPLE2
  15. res1: Sample.PSSampleEnum = sample.sample2
  16.  
  17. scala> SampleEnum.SAMPLE.path
  18. res2: String = sample
  19.  
  20. scala> SampleEnum.SAMPLE2.path
  21. res3: String = sample2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement