Last active
March 18, 2016 11:34
-
-
Save gkazior/642ef133004be6f7abd8 to your computer and use it in GitHub Desktop.
Scala enum - pattern when I do not use java enum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Ensure statuses */ | |
object EnsureStatus { | |
sealed trait Type | |
case object Created extends Type // cannot match so need to create | |
case object Modified extends Type // matched and modified | |
case object NotModified extends Type // matched and not modified | |
val statuses = (Created, Modified, NotModified) | |
} | |
val status: EnsureStatus.Type = EnsureStatus.Created |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment