Skip to content

Helper to create enums out of a 'sealed trait' and some 'case object's

Notifications You must be signed in to change notification settings

marcesquerra/enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enum

Helper to create enums out of a 'sealed trait' and some 'case object's

Usage

import com.bryghts.enumeration._

sealed trait CardSuit

object CardSuit extends Enum[CardSuit] {
  case object Spades   extends CardSuit
  case object Hearts   extends CardSuit
  case object Diamonds extends CardSuit
  case object Clubs    extends CardSuit
}

This adds to the CardSuit object this capabilities:

CardSuit("Spades")   // returns Some(CardSuit.Spades)
CardSuit("Bastos")   // returns None
CardSuit.values      // returns Set(CardSuit.Spades, CardSuit.Hearts, CardSuit.Diamonds, CardSuit.Clubs)

SBT Dependency

libraryDependencies += "com.bryghts.enum" %% "enum" % "0.1.4"

ScalaDoc

http://marcesquerra.github.io/enum/latest/api/

About

Helper to create enums out of a 'sealed trait' and some 'case object's

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages