{"id":15030370,"url":"https://github.com/lloydmeta/enumeratum","last_synced_at":"2025-04-23T20:59:47.637Z","repository":{"id":24196047,"uuid":"27587274","full_name":"lloydmeta/enumeratum","owner":"lloydmeta","description":"A type-safe, reflection-free, powerful enumeration implementation for Scala with exhaustive pattern match warnings and helpful integrations.","archived":false,"fork":false,"pushed_at":"2025-03-28T15:52:45.000Z","size":1430,"stargazers_count":1201,"open_issues_count":34,"forks_count":150,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-23T20:59:21.260Z","etag":null,"topics":["enum","enumerations","integrations","scala","value-enum"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lloydmeta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-05T10:49:34.000Z","updated_at":"2025-04-02T00:37:54.000Z","dependencies_parsed_at":"2023-01-14T00:33:55.964Z","dependency_job_id":"8e148162-e49b-4b9e-827a-663f7cec630c","html_url":"https://github.com/lloydmeta/enumeratum","commit_stats":{"total_commits":522,"total_committers":98,"mean_commits":5.326530612244898,"dds":0.4329501915708812,"last_synced_commit":"e3869a725786013d4725ea90f2ec81d84e661206"},"previous_names":[],"tags_count":105,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydmeta%2Fenumeratum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydmeta%2Fenumeratum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydmeta%2Fenumeratum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydmeta%2Fenumeratum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lloydmeta","download_url":"https://codeload.github.com/lloydmeta/enumeratum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514767,"owners_count":21443208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enum","enumerations","integrations","scala","value-enum"],"created_at":"2024-09-24T20:13:12.539Z","updated_at":"2025-04-23T20:59:47.519Z","avatar_url":"https://github.com/lloydmeta.png","language":"Scala","readme":"# Enumeratum [![Continuous integration](https://github.com/lloydmeta/enumeratum/actions/workflows/ci.yml/badge.svg)](https://github.com/lloydmeta/enumeratum/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/lloydmeta/enumeratum/branch/master/graph/badge.svg?token=HNg3LDxnuK)](https://codecov.io/gh/lloydmeta/enumeratum) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a71a20d8678f4ed3a5b74b0659c1bc4c)](https://www.codacy.com/app/lloydmeta/enumeratum?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=lloydmeta/enumeratum\u0026amp;utm_campaign=Badge_Grade) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum_2.12) [![Scala.js](https://www.scala-js.org/assets/badges/scalajs-0.6.0.svg)](https://www.scala-js.org) [![Join the chat at https://gitter.im/lloydmeta/enumeratum](https://badges.gitter.im/lloydmeta/enumeratum.svg)](https://gitter.im/lloydmeta/enumeratum?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\nEnumeratum is a type-safe and powerful enumeration implementation for Scala that offers exhaustive pattern match warnings,\nintegrations with popular Scala libraries, and idiomatic usage that won't break your IDE. It aims to be similar enough\nto Scala's built in `Enumeration` to be easy-to-use and understand while offering more flexibility, type-safety (see [this blog\npost describing erasure on Scala's `Enumeration`](http://underscore.io/blog/posts/2014/09/03/enumerations.html)), and\nricher enum values without having to maintain your own collection of values.\n\nEnumeratum has the following niceties:\n\n- Zero dependencies\n- Performant: Faster than`Enumeration` in the standard library (see [benchmarks](#benchmarking))\n- Allows your Enum members to be full-fledged normal objects with methods, values, inheritance, etc.\n- [`ValueEnum`s](#valueenum) that map to various primitive values and have compile-time uniqueness constraints.\n- Idiomatic: you're very clearly still writing Scala, and no funny colours in your IDE means less cognitive overhead for your team\n- Simplicity; most of the complexity in this lib is in its macro, and the macro is fairly simple conceptually\n- No usage of reflection at runtime. This may also help with performance but it means Enumeratum is compatible with ScalaJS and other\n  environments where reflection is a best effort (such as Android)\n- No usage of `synchronized`, which may help with performance and deadlocks prevention\n- All magic happens at compile-time so you know right away when things go awry\n- Comprehensive automated testing to make sure everything is in tip-top shape\n\nEnumeratum is published for Scala 2.12.x, 2.13.x, 3.x as well as ScalaJS and ScalaNative.\n\nNote that there are a couple of limitations for 3.x:\n* All \"immediate\" parent types of enum entries need to be `sealed` (reasoning [here](https://github.com/lloydmeta/enumeratum/pull/349#discussion_r1034715979))\n* The `-Yretain-trees` Scalac option must be set when using ValueEnums\n\nIntegrations are available for:\n\n- [Play](https://www.playframework.com/): JVM only\n- [Play JSON](https://www.playframework.com/documentation/2.8.x/ScalaJson): JVM (included in Play integration but also available separately) and ScalaJS\n- [Circe](https://github.com/travisbrown/circe): JVM and ScalaJS\n- [ReactiveMongo BSON](reactivemongo.org/releases/1.0/documentation/bson/overview.html): JVM only\n- [Argonaut](http://argonaut.io): JVM and ScalaJS\n- [Json4s](http://json4s.org): JVM only\n- [ScalaCheck](https://www.scalacheck.org): JVM and ScalaJS\n- [Slick](http://slick.lightbend.com/): JVM only\n- [Quill](http://getquill.io): JVM and ScalaJS\n- [sttp tapir](https://github.com/softwaremill/tapir): JVM and ScalaJS\n- [Scalafix](https://github.com/OlegYch/enumeratum-scalafix)\n\n### Table of Contents\n\n1. [Quick start](#quick-start)\n    - [SBT](#sbt)\n    - [Usage](#usage)\n2. [More examples](#more-examples)\n    - [Enum](#enum)\n      - [Manual override of name](#manual-override-of-name)\n      - [Mixins to override the name](#mixins-to-override-the-name)\n    - [ValueEnum](#valueenum)\n3. [ScalaJS](#scalajs)\n4. [Play integration](#play-integration)\n5. [Play JSON integration](#play-json)\n6. [Circe integration](#circe)\n8. [ReactiveMongo BSON integration](#reactivemongo-bson)\n9. [Argonaut integration](#argonaut)\n10. [Json4s integration](#json4s)\n11. [Slick integration](#slick-integration)\n12. [ScalaCheck](#scalacheck)\n13. [Quill integration](#quill)\n14. [Cats integration](#cats)\n15. [Doobie integration](#doobie)\n16. [Anorm integration](#anorm)\n17. [Benchmarking](#benchmarking)\n18. [Publishing](#publishing)\n\n\n## Quick start\n\n### SBT\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum_2.12)\n\nIn `build.sbt`, set the Enumeratum version in a variable (for the latest version, set `val enumeratumVersion = ` the version you see\nin the Maven badge above).\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum\" % enumeratumVersion\n)\n```\n\nEnumeratum has different integrations that can be added to your build à la carte. For more info, see the respective sections in\n[the Table of Contents](#table-of-contents)\n\n### Usage\n\nUsing Enumeratum is simple. Just declare your own sealed trait or class `A` that extends `EnumEntry` and implement it as case objects inside\nan object that extends from `Enum[A]` as shown below.\n\n```scala\n\nimport enumeratum._\n\nsealed trait Greeting extends EnumEntry\n\nobject Greeting extends Enum[Greeting] {\n\n  /*\n   `findValues` is a protected method that invokes a macro to find all `Greeting` object declarations inside an `Enum`\n\n   You use it to implement the `val values` member\n  */\n  val values = findValues\n\n  case object Hello   extends Greeting\n  case object GoodBye extends Greeting\n  case object Hi      extends Greeting\n  case object Bye     extends Greeting\n\n}\n\n// Object Greeting has a `withName(name: String)` method\nGreeting.withName(\"Hello\")\n// =\u003e res0: Greeting = Hello\n\nGreeting.withName(\"Haro\")\n// =\u003e java.lang.NoSuchElementException: Haro is not a member of Enum (Hello, GoodBye, Hi, Bye)\n\n// A safer alternative would be to use `withNameOption(name: String)` method which returns an Option[Greeting]\nGreeting.withNameOption(\"Hello\")\n// =\u003e res1: Option[Greeting] = Some(Hello)\n\nGreeting.withNameOption(\"Haro\")\n// =\u003e res2: Option[Greeting] = None\n\n// It is also possible to use strings case insensitively\nGreeting.withNameInsensitive(\"HeLLo\")\n// =\u003e res3: Greeting = Hello\n\nGreeting.withNameInsensitiveOption(\"HeLLo\")\n// =\u003e res4: Option[Greeting] = Some(Hello)\n\n// Uppercase-only strings may also be used\nGreeting.withNameUppercaseOnly(\"HELLO\")\n// =\u003e res5: Greeting = Hello\n\nGreeting.withNameUppercaseOnlyOption(\"HeLLo\")\n// =\u003e res6: Option[Greeting] = None\n\n// Similarly, lowercase-only strings may also be used\nGreeting.withNameLowercaseOnly(\"hello\")\n// =\u003e res7: Greeting = Hello\n\nGreeting.withNameLowercaseOnlyOption(\"hello\")\n// =\u003e res8: Option[Greeting] = Some(Hello)\n```\n\nNote that by default, `findValues` will return a `Seq` with the enum members listed in written-order (relevant if you want to\nuse the `indexOf` method).\n\nEnum members found in nested objects will be included by `findValues` as well, and will appear in the order they are\nwritten in the companion object, top to bottom. Note that enum members declared in traits or classes will *not* be\ndiscovered by `findValues`. For example:\n\n```scala\nsealed trait Nesting extends EnumEntry\nobject Nesting extends Enum[Nesting] {\n  val values = findValues\n\n  case object Hello extends Nesting\n  object others {\n    case object GoodBye extends Nesting\n  }\n  case object Hi extends Nesting\n  class InnerClass {\n    case object NotFound extends Nesting\n  }\n}\n\nNesting.values\n// =\u003e res0: scala.collection.immutable.IndexedSeq[Nesting] = Vector(Hello, GoodBye, Hi)\n```\n\nFor an interactive demo, checkout this [Scastie snippet](https://scastie.scala-lang.org/ELNlwiZSRO61vxUHer4Ieg).\n\n## More examples\n\n### Enum\n\nContinuing from the `Greeting` enum declared in [the quick-start section](#usage):\n\n```scala\nimport Greeting._\n\ndef tryMatching(v: Greeting): Unit = v match {\n  case Hello   =\u003e println(\"Hello\")\n  case GoodBye =\u003e println(\"GoodBye\")\n  case Hi      =\u003e println(\"Hi\")\n}\n\n/**\nPattern match warning ...\n\n\u003cconsole\u003e:24: warning: match may not be exhaustive.\nIt would fail on the following input: Bye\n       def tryMatching(v: Greeting): Unit = v match {\n\n*/\n\nGreeting.indexOf(Bye)\n// =\u003e res2: Int = 3\n\n```\n\nThe name is taken from the `toString` method of the particular\n`EnumEntry`. This behavior can be changed in two ways.\n\n\n#### Manual override of name\nThe first way to change the name behaviour is to manually override the `def entryName: String` method.\n\n```scala\n\nimport enumeratum._\n\nsealed abstract class State(override val entryName: String) extends EnumEntry\n\nobject State extends Enum[State] {\n\n   val values = findValues\n\n   case object Alabama extends State(\"AL\")\n   case object Alaska  extends State(\"AK\")\n   // and so on and so forth.\n}\n\nimport State._\n\nState.withName(\"AL\")\n\n```\n\n#### Mixins to override the name\n\nThe second way to override the name behaviour is to mixin the stackable traits provided for common string\nconversions, `Snakecase`, `UpperSnakecase`, `CapitalSnakecase`, `Hyphencase`, `UpperHyphencase`, `CapitalHyphencase`, `Dotcase`, `UpperDotcase`, `CapitalDotcase`, `Words`, `UpperWords`, `CapitalWords`, `Camelcase`, `LowerCamelcase`, `Uppercase`, `Lowercase`, and `Uncapitalised`.\n\n```scala\n\nimport enumeratum._\nimport enumeratum.EnumEntry._\n\nsealed trait Greeting extends EnumEntry with Snakecase\n\nobject Greeting extends Enum[Greeting] {\n\n  val values = findValues\n\n  case object Hello        extends Greeting\n  case object GoodBye      extends Greeting\n  case object ShoutGoodBye extends Greeting with Uppercase\n\n}\n\nGreeting.withName(\"hello\")\nGreeting.withName(\"good_bye\")\nGreeting.withName(\"SHOUT_GOOD_BYE\")\n\n```\n\n### ValueEnum\n\nAsides from enumerations that resolve members from `String` _names_, Enumeratum also supports `ValueEnum`s, enums that resolve\nmembers from simple _values_ like `Int`, `Long`, `Short`, `Char`, `Byte`, and `String` (without support for runtime transformations).\n\nThese enums are not modelled after `Enumeration` from standard lib, and therefore have the added ability to make sure, at compile-time,\nthat multiple members do not share the same value.\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class LibraryItem(val value: Int, val name: String) extends IntEnumEntry\n\nobject LibraryItem extends IntEnum[LibraryItem] {\n\n\n  case object Book     extends LibraryItem(value = 1, name = \"book\")\n  case object Movie    extends LibraryItem(name = \"movie\", value = 2)\n  case object Magazine extends LibraryItem(3, \"magazine\")\n  case object CD       extends LibraryItem(4, name = \"cd\")\n  // case object Newspaper extends LibraryItem(4, name = \"newspaper\") \u003c-- will fail to compile because the value 4 is shared\n\n  /*\n  val five = 5\n  case object Article extends LibraryItem(five, name = \"article\") \u003c-- will fail to compile because the value is not a literal\n  */\n\n  val values = findValues\n\n}\n\nassert(LibraryItem.withValue(1) == LibraryItem.Book)\n\nLibraryItem.withValue(10) // =\u003e java.util.NoSuchElementException:\n```\n\nIf you want to allow aliases in your enumeration, i.e. multiple entries that share the same value, you can extend the\n`enumeratum.values.AllowAlias` trait:\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class Judgement(val value: Int) extends IntEnumEntry with AllowAlias\n\nobject Judgement extends IntEnum[Judgement] {\n\n  case object Good extends Judgement(1)\n  case object OK extends Judgement(2)\n  case object Meh extends Judgement(2)\n  case object Bad extends Judgement(3)\n\n  val values = findValues\n\n}\n```\n\nCalling `withValue` with an aliased value will return one of the corresponding entries. Which one it returns is undefined:\n\n```scala\nassert(Judgement.withValue(2) == Judgement.OK || Judgement.withValue(2) == Judgement.Meh)\n```\n\n**Restrictions**\n- `ValueEnum`s must have their value members implemented as literal values.\n\n\n## ScalaJS\n\nIn a ScalaJS project, add the following to `build.sbt`:\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum_2.12)\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %%% \"enumeratum\" % enumeratumVersion\n)\n```\n\nAs expected, usage is exactly the same as normal Scala.\n\n## Play Integration\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-play_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-play_2.13)\n\nThe `enumeratum-play` project is published separately and gives you access to various tools\nto help you avoid boilerplate in your Play project.\n\n### SBT\n\nFor enumeratum with full Play support:\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-play\" % enumeratumPlayVersion\n)\n```\n\n#### Dependencies and compatibility notes\n- As of version 1.8, `enumeratum-play` requires Scala 2.13+ and Play \u003e= 3\n\n### Usage\n\n#### PlayEnum\n\nThe included `PlayEnum` trait is probably going to be the most interesting as it includes a bunch\nof built-in implicits like Json formats, Path bindables, Query string bindables, and Form field support.\n\nFor example:\n\n```scala\npackage enums\n\nimport enumeratum._\n\nsealed trait Greeting extends EnumEntry\n\nobject Greeting extends PlayEnum[Greeting] {\n\n  val values = findValues\n\n  case object Hello   extends Greeting\n  case object GoodBye extends Greeting\n  case object Hi      extends Greeting\n  case object Bye     extends Greeting\n\n}\n\n/*\n  Then make sure to import your PlayEnums into your routes in your Build.scala\n  or build.sbt so that you can use them in your routes file.\n\n  `routesImport += \"enums._\"`\n*/\n\n\n// You can also use the String Interpolating Routing DSL:\n\nimport play.api.routing.sird._\nimport play.api.routing._\nimport play.api.mvc._\nRouter.from {\n    case GET(p\"/hello/${Greeting.fromPath(greeting)}\") =\u003e Action {\n      Results.Ok(s\"$greeting\")\n    }\n}\n\n```\n\n#### PlayValueEnums\n\nThere are `IntPlayEnum`, `LongPlayEnum`, and `ShortPlayEnum` traits for use with `IntEnumEntry`, `LongEnumEntry`, and\n`ShortEnumEntry` respectively that provide Play-specific implicits as with normal `PlayEnum`. For example:\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class PlayLibraryItem(val value: Int, val name: String) extends IntEnumEntry\n\ncase object PlayLibraryItem extends IntPlayEnum[PlayLibraryItem] {\n\n  // A good mix of named, unnamed, named + unordered args\n  case object Book     extends PlayLibraryItem(value = 1, name = \"book\")\n  case object Movie    extends PlayLibraryItem(name = \"movie\", value = 2)\n  case object Magazine extends PlayLibraryItem(3, \"magazine\")\n  case object CD       extends PlayLibraryItem(4, name = \"cd\")\n\n  val values = findValues\n\n}\n\nimport play.api.libs.json.{ JsNumber, JsString, Json =\u003e PlayJson }\nPlayLibraryItem.values.foreach { item =\u003e\n    assert(PlayJson.toJson(item) == JsNumber(item.value))\n}\n```\n\n#### PlayFormFieldEnum\n`PlayEnum` extends the trait `PlayFormFieldEnum` wich offers `formField` for mapping within a `play.api.data.Form` object.\n\n```scala\nimport play.api.data.Form\nimport play.api.data.Forms._\n\nobject GreetingForm {\n  val form = Form(\n    mapping(\n      \"name\"     -\u003e nonEmptyText,\n      \"greeting\" -\u003e Greeting.formField\n    )(Data.apply)(Data.unapply)\n  )\n\n  case class Data(\n    name: String,\n    greeting: Greeting)\n}\n```\n\nAnother alternative (if for example your `Enum` can't extend `PlayEnum` or `PlayFormFieldEnum`) is to create an implicit `Format`\nand bring it into scope using Play's `of`, i.e.\n\n```scala\nimport play.api.data.Form\nimport play.api.data.Forms._\n\nobject Formats {\n  implicit val greetingFormat = enumeratum.Forms.format(Greeting)\n}\n\nobject GreetingForm {\n  import Formats._\n\n  val form = Form(\n      mapping(\n        \"name\"     -\u003e nonEmptyText,\n        \"greeting\" -\u003e of[Greeting]\n      )(Data.apply)(Data.unapply)\n    )\n\n    case class Data(\n      name: String,\n      greeting: Greeting)\n\n}\n```\n\n## Play JSON\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-play-json_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-play-json_2.13)\n\nThe `enumeratum-play-json` project is published separately and gives you access to Play's auto-generated boilerplate\nfor JSON serialization in your Enum's.\n\n### SBT\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-play-json\" % enumeratumPlayJsonVersion\n)\n```\n\n### Usage\n\n#### PlayJsonEnum\n\nThere are also `PlayInsensitiveJsonEnum`, `PlayLowercaseJsonEnum`, and `PlayUppercaseJsonEnum` traits for use. For example:\n\n```scala\nimport enumeratum.{ PlayJsonEnum, Enum, EnumEntry }\n\nsealed trait Greeting extends EnumEntry\n\nobject Greeting extends Enum[Greeting] with PlayJsonEnum[Greeting] {\n\n  val values = findValues\n\n  case object Hello   extends Greeting\n  case object GoodBye extends Greeting\n  case object Hi      extends Greeting\n  case object Bye     extends Greeting\n\n}\n\n```\n\n#### PlayJsonValueEnum\n\nThere are `IntPlayJsonValueEnum`, `LongPlayJsonValueEnum`, and `ShortPlayJsonValueEnum` traits for use with `IntEnumEntry`, `LongEnumEntry`, and\n`ShortEnumEntry` respectively. For example:\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class JsonDrinks(val value: Short, name: String) extends ShortEnumEntry\n\ncase object JsonDrinks extends ShortEnum[JsonDrinks] with ShortPlayJsonValueEnum[JsonDrinks] {\n\n  case object OrangeJuice extends JsonDrinks(value = 1, name = \"oj\")\n  case object AppleJuice  extends JsonDrinks(value = 2, name = \"aj\")\n  case object Cola        extends JsonDrinks(value = 3, name = \"cola\")\n  case object Beer        extends JsonDrinks(value = 4, name = \"beer\")\n\n  val values = findValues\n\n}\n\nimport play.api.libs.json.{ JsNumber, JsString, Json =\u003e PlayJson, JsSuccess }\n\n// Use to deserialise numbers to enum members directly\nJsonDrinks.values.foreach { drink =\u003e\n    assert(PlayJson.toJson(drink) == JsNumber(drink.value))\n}\nassert(PlayJson.fromJson[JsonDrinks](JsNumber(3)) == JsSuccess(JsonDrinks.Cola))\nassert(PlayJson.fromJson[JsonDrinks](JsNumber(19)).isError)\n```\n\n## Circe\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-circe_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-circe_2.12)\n\n### SBT\n\nTo use enumeratum with [Circe](https://github.com/travisbrown/circe):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-circe\" % enumeratumCirceVersion\n)\n```\n\nTo use with ScalaJS:\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %%% \"enumeratum-circe\" % enumeratumCirceVersion\n)\n```\n\n### Usage\n\n#### Enum\n\n```scala\nimport enumeratum._\n\nsealed trait ShirtSize extends EnumEntry\n\ncase object ShirtSize extends Enum[ShirtSize] with CirceEnum[ShirtSize] {\n\n  case object Small  extends ShirtSize\n  case object Medium extends ShirtSize\n  case object Large  extends ShirtSize\n\n  val values = findValues\n\n}\n\nimport io.circe.Json\nimport io.circe.syntax._\n\nShirtSize.values.foreach { size =\u003e\n    assert(size.asJson == Json.fromString(size.entryName))\n}\n\n```\n\n#### ValueEnum\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class CirceLibraryItem(val value: Int, val name: String) extends IntEnumEntry\n\ncase object CirceLibraryItem extends IntEnum[CirceLibraryItem] with IntCirceEnum[CirceLibraryItem] {\n\n  // A good mix of named, unnamed, named + unordered args\n  case object Book     extends CirceLibraryItem(value = 1, name = \"book\")\n  case object Movie    extends CirceLibraryItem(name = \"movie\", value = 2)\n  case object Magazine extends CirceLibraryItem(3, \"magazine\")\n  case object CD       extends CirceLibraryItem(4, name = \"cd\")\n\n  val values = findValues\n\n}\n\nimport io.circe.Json\nimport io.circe.syntax._\n\nCirceLibraryItem.values.foreach { item =\u003e\n    assert(item.asJson == Json.fromInt(item.value))\n}\n```\n\n## ReactiveMongo BSON\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-reactivemongo-bson_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-reactivemongo-bson_2.12)\n\nThe `enumeratum-reactivemongo-bson` project is published separately and gives you access to ReactiveMongo's auto-generated boilerplate\nfor BSON serialization in your Enum's.\n\n### SBT\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-reactivemongo-bson\" % enumeratumReactiveMongoVersion\n)\n```\n\n### Usage\n\n#### ReactiveMongoBsonEnum\n\nFor example:\n\n```scala\nimport enumeratum.{ ReactiveMongoBsonEnum, Enum, EnumEntry }\n\nsealed trait Greeting extends EnumEntry\n\nobject Greeting extends Enum[Greeting] with ReactiveMongoBsonEnum[Greeting] {\n\n  val values = findValues\n\n  case object Hello   extends Greeting\n  case object GoodBye extends Greeting\n  case object Hi      extends Greeting\n  case object Bye     extends Greeting\n\n}\n\n```\n\n#### ReactiveMongoBsonValueEnum\n\nThere are `IntReactiveMongoBsonValueEnum`, `LongReactiveMongoBsonValueEnum`, and `ShortReactiveMongoBsonValueEnum` traits for use with `IntEnumEntry`, `LongEnumEntry`, and\n`ShortEnumEntry` respectively. For example:\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class BsonDrinks(val value: Short, name: String) extends ShortEnumEntry\n\ncase object BsonDrinks extends ShortEnum[BsonDrinks] with ShortReactiveMongoBsonValueEnum[BsonDrinks] {\n\n  case object OrangeJuice extends BsonDrinks(value = 1, name = \"oj\")\n  case object AppleJuice  extends BsonDrinks(value = 2, name = \"aj\")\n  case object Cola        extends BsonDrinks(value = 3, name = \"cola\")\n  case object Beer        extends BsonDrinks(value = 4, name = \"beer\")\n\n  val values = findValues\n\n}\n\nimport reactivemongo.api.bson._\n\n// Use to deserialise numbers to enum members directly\nBsonDrinks.values.foreach { drink =\u003e\n  val writer = implicitly[BSONWriter[BsonDrinks]]\n\n  assert(writer.write(drink) == BSONInteger(drink.value))\n}\n\nval reader = implicitly[BSONReader[BsonDrinks]]\n\nassert(reader.read(BSONInteger(3)) == BsonDrinks.Cola)\n```\n\n## Argonaut\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-argonaut_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-argonaut_2.12)\n\n### SBT\n\nTo use enumeratum with [Argonaut](http://www.argonaut.io):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-argonaut\" % enumeratumArgonautVersion\n)\n```\n\n### Usage\n\n#### Enum\n\n```scala\nimport enumeratum._\n\nsealed trait TrafficLight extends EnumEntry\nobject TrafficLight extends Enum[TrafficLight] with ArgonautEnum[TrafficLight] {\n  case object Red    extends TrafficLight\n  case object Yellow extends TrafficLight\n  case object Green  extends TrafficLight\n  val values = findValues\n}\n\nimport argonaut._\nimport Argonaut._\n\nTrafficLight.values.foreach { entry =\u003e\n    assert(entry.asJson == entry.entryName.asJson)\n}\n\n```\n\n#### ValueEnum\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class ArgonautDevice(val value: Short) extends ShortEnumEntry\ncase object ArgonautDevice\n    extends ShortEnum[ArgonautDevice]\n    with ShortArgonautEnum[ArgonautDevice] {\n  case object Phone   extends ArgonautDevice(1)\n  case object Laptop  extends ArgonautDevice(2)\n  case object Desktop extends ArgonautDevice(3)\n  case object Tablet  extends ArgonautDevice(4)\n\n  val values = findValues\n}\n\nimport argonaut._\nimport Argonaut._\n\nArgonautDevice.values.foreach { item =\u003e\n    assert(item.asJson == item.value.asJson)\n}\n```\n\n## Json4s\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-json4s_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-json4s_2.12)\n\n### SBT\n\nTo use enumeratum with [Json4s](http://json4s.org):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-json4s\" % enumeratumJson4sVersion\n)\n```\n\n### Usage\n\n#### Enum\n\n```scala\nimport enumeratum._\n\nsealed trait TrafficLight extends EnumEntry\nobject TrafficLight extends Enum[TrafficLight] /* nothing extra here */ {\n  case object Red    extends TrafficLight\n  case object Yellow extends TrafficLight\n  case object Green  extends TrafficLight\n\n  val values = findValues\n}\n\nimport org.json4s.DefaultFormats\n\nimplicit val formats = DefaultFormats + Json4s.serializer(TrafficLight)\n\n```\n\n#### ValueEnum\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class Device(val value: Short) extends ShortEnumEntry\ncase object Device\n  extends ShortEnum[Device] /* nothing extra here */  {\n  case object Phone   extends Device(1)\n  case object Laptop  extends Device(2)\n  case object Desktop extends Device(3)\n  case object Tablet  extends Device(4)\n\n  val values = findValues\n}\n\nimport org.json4s.DefaultFormats\n\nimplicit val formats = DefaultFormats + Json4s.serializer(Device)\n\n```\n\n## ScalaCheck\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-scalacheck_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-scalacheck_2.12)\n\n### SBT\n\nTo use enumeratum with [ScalaCheck](https://www.scalacheck.org):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-scalacheck\" % enumeratumScalacheckVersion\n)\n```\n\n### Usage\n\n#### Enum\n\nGiven the enum declared in [the quick-start section](#usage), you can get an `Arbitrary[Greeting]` (to generate instances of `Greeting`) and a `Cogen[Greeting]` (to generate instances of `Greeting =\u003e (A: Arbitrary)`) by importing generators in the scope of your tests:\n\n```scala\nimport enumeratum.scalacheck._\n```\n\n#### ValueEnum\n\nSimilarly, you can get `Arbitrary` and `Cogen` instances for every `ValueEnum` subtype by importing generators in the scope of your tests:\n\n```scala\nimport enumeratum.values.scalacheck._\n```\n\n## Quill\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-quill_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-quill_2.12)\n\n### SBT\n\nTo use enumeratum with [Quill](http://getquill.io):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-quill\" % enumeratumQuillVersion\n)\n```\n\nTo use with ScalaJS:\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %%% \"enumeratum-quill\" % enumeratumQuillVersion\n)\n```\n\n### Usage\n\n#### Enum\n\n```scala\nimport enumeratum._\n\nsealed trait ShirtSize extends EnumEntry\n\ncase object ShirtSize extends Enum[ShirtSize] with QuillEnum[ShirtSize] {\n\n  case object Small  extends ShirtSize\n  case object Medium extends ShirtSize\n  case object Large  extends ShirtSize\n\n  val values = findValues\n\n}\n\ncase class Shirt(size: ShirtSize)\n\nimport io.getquill._\n\nlazy val ctx = new PostgresJdbcContext(SnakeCase, \"ctx\")\nimport ctx._\n\nctx.run(query[Shirt].insert(_.size -\u003e lift(ShirtSize.Small: ShirtSize)))\n\nctx.run(query[Shirt]).foreach(println)\n```\n- Note that a type ascription to the `EnumEntry` trait (eg. `ShirtSize.Small: ShirtSize`) is required when binding hardcoded `EnumEntry`s\n\n#### ValueEnum\n\n```scala\nimport enumeratum._\n\nsealed abstract class ShirtSize(val value: Int) extends IntEnumEntry\n\ncase object ShirtSize extends IntEnum[ShirtSize] with IntQuillEnum[ShirtSize] {\n\n  case object Small  extends ShirtSize(1)\n  case object Medium extends ShirtSize(2)\n  case object Large  extends ShirtSize(3)\n\n  val values = findValues\n\n}\n\ncase class Shirt(size: ShirtSize)\n\nimport io.getquill._\n\nlazy val ctx = new PostgresJdbcContext(SnakeCase, \"ctx\")\nimport ctx._\n\nctx.run(query[Shirt].insert(_.size -\u003e lift(ShirtSize.Small: ShirtSize)))\n\nctx.run(query[Shirt]).foreach(println)\n```\n- Note that a type ascription to the `ValueEnumEntry` abstract class (eg. `ShirtSize.Small: ShirtSize`) is required when binding hardcoded `ValueEnumEntry`s\n- `quill-cassandra` currently does not support `ShortEnum` and `ByteEnum` (see [getquill/quill#1009](https://github.com/getquill/quill/issues/1009))\n- `quill-orientdb` currently does not support `ByteEnum` (see [getquill/quill#1029](https://github.com/getquill/quill/issues/1029))\n\n## Slick integration\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-slick_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-slick_2.12)\n\n### Column Mappings\nIn order to use your enumeratum Enums in Slick tables as columns, you will\n need to construct instances of `MappedColumnType` and make them available\n where you define and query your slick tables. In order to more easily\n construct these instances, the enumeratum-slick integration provides a trait\n `enumeratum.SlickEnumSupport`. This trait provides a method `mappedColumnTypeForEnum`\n (and variants) for constructing a mapped column type for your enum. For example\n if you want to use `Enum[Greeting]` in your slick table, mix in `SlickEnumSupport`\n where you define your table.\n```scala\ntrait GreetingRepository extends SlickEnumSupport {\n  val profile: slick.jdbc.Profile\n  implicit lazy val greetingMapper = mappedColumnTypeForEnum(Greeting)\n  class GreetingTable(tag: Tag) extends Table[(String, Greeting)](tag, \"greeting\") {\n    def id = column[String](\"id\", O.PrimaryKey)\n    def greeting = column[Greeting](\"greeting\") // Maps to a varchar/text column\n\n    def * = (id, greeting)\n  }\n\n```\n\n### ValueEnum Mappings\n\nIf you want to represent a `ValueEnum` by its `value` rather than its string\nname, simply mix in `SlickValueEnumSupport` and proceed mostly as above:\n```scala\nimplicit lazy val libraryItemMapper = mappedColumnTypeForIntEnum(LibraryItem)\n...\ndef item = column[LibraryItem](\"LIBRARY_ITEM\") // Maps to a numeric column\n```\n\n### Common Mappers\n\nAn alternate approach which is useful when mappers need to be shared across\nrepositories (perhaps for something common like a \"Status\" enum) is to define\nyour mappers in a module on their own, then make use of them in your repositories:\n```scala\ntrait CommonMappers extends SlickEnumSupport {\n  val profile: Profile\n  implicit lazy val statusMapper = mappedColumnTypeForEnum(Status)\n  ...\n}\ntrait UserRepository extends CommonMappers {\n  val profile: Profile\n  class UserTable(tag: Tag) extends Table[UserRow](tag, \"user\") {\n    ...\n    def status = column[Status](\"status\")\n    ...\n  }\n}\n```\n\n### Querying by enum column types\n\nNote that because your enum values are singleton objects, you may get errors when you try to use them in Slick queries like\nthe following:\n\n```scala\n.filter(_.trafficLight === TrafficLight.Red)\n```\n\nThis is because `TrafficLight.Red` in the above example is inferred to\nbe of its unique type (`TrafficLight.Red`) rather than `TrafficLight`,\nthus causing a failure to find your mapping. In order to fix this,\nsimply assist the compiler by ascribing the type to be `TrafficLight`:\n\n```scala\n.filter(_.trafficLight === (TrafficLight.Red: TrafficLight))\n```\n\nA way around this if you find the type expansion offensive is to define\nval accessors for your enum entries that are typed as the parent type.\nYou can do this inside your Enums companion object or more locally:\n```scala\nval red: TrafficLight = Red // Not red: TrafficLight.Red = Red\nval yellow: TrafficLight = Yellow\nval green: TrafficLight = Green\n...\n.filter(_.trafficLight === red)\n```\n\n### Interpolated / Plain SQL integration\n\nIf you want to use slick interpolated SQL queries you can use the provided\nconstructors to instantiate instances of `GetResult[_]` and `SetParameter[_]`\nfor your enum:\n```scala\nimport SlickEnumPlainSqlSupport._\n```\nOr mix it in...\n```scala\ntrait Foo extends SlickEnumPlainSqlSupport {\n  ...\n}\n```\nThen define your instances:\n```scala\nimplicit val greetingGetResult = getResultForEnum(Greeting)\nimplicit val greetingOptionGetResult = optionalGetResultForEnum(Greeting)\nimplicit val greetingSetParameter = setParameterForEnum(Greeting)\nimplicit val greetingOptionSetParameter = optionalSetParameterForEnum(Greeting)\n```\n\n## Cats\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-cats_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-cats_2.12)\n\n### SBT\n\nTo use enumeratum with [Cats](https://github.com/typelevel/cats):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-cats\" % enumeratumCatsVersion\n)\n```\n\nTo use with ScalaJS:\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %%% \"enumeratum-cats\" % enumeratumCatsVersion\n)\n```\n\n### Usage\n\nThis enumeratum module is mostly useful for generic derivation - providing instances for `Eq`, `Show` and `Hash`. So if you have structures (for example case classes) which\ncontain enum values, you get the instances for the enum itself \"for free\". But it can be useful for standalone usage as,\nproviding type-safe comparison and hashing.\n\n#### Enum\n\n```scala\nimport enumeratum._\n\nsealed trait ShirtSize extends EnumEntry\n\ncase object ShirtSize extends Enum[ShirtSize] with CatsEnum[ShirtSize] {\n\n  case object Small   extends ShirtSize\n  case object Medium  extends ShirtSize\n  case object Large   extends ShirtSize\n\n  val values = findValues\n\n}\n\nimport cats.syntax.eq._\nimport cats.syntax.show._\n\nval shirtSizeOne: ShirtSize = ...\nval shirtSizeTwo: ShirtSize = ...\n\nif(shirtSizeOne === shirtSizeTwo) { // note the third equals\n    printf(\"We got the same size, its hash is: %i\", implicitly[Hash[TrafficLight]].hash(shirtSizeOne))\n} else {\n    printf(\"Shirt sizes mismatch: %s =!= %s\", shirtSizeOne.show, shirtSizeTwo.show)\n}\n```\n\n#### ValueEnum\n\nThere are two implementations for `ValueEnum`:\n* `CatsValueEnum` provides the same functionality as `CatsEnum` (except `Hash`)\n* `CatsOrderValueEnum` provides the same functionality as `CatsValueEnum` plus an instance of `cats.Order` (due to Scala 2 trait limitations, it's an `abstract class`, check out `CatsCustomOrderValueEnum` if you need a `trait`)\n\n```scala\nimport enumeratum.values._\n\nsealed abstract class CatsPriority(val value: Int, val name: String) extends IntEnumEntry\n\ncase object CatsPriority extends IntEnum[CatsPriority] with CatsOrderValueEnum[Int, CatsPriority] {\n\n  // A good mix of named, unnamed, named + unordered args\n  case object Low         extends CatsPriority(value = 1, name = \"low\")\n  case object Medium      extends CatsPriority(name = \"medium\", value = 2)\n  case object High        extends CatsPriority(3, \"high\")\n  case object SuperHigh   extends CatsPriority(4, name = \"super_high\")\n\n  val values = findValues\n\n}\n\nimport cats.instances.int._\nimport cats.instances.list._\nimport cats.syntax.order._\nimport cats.syntax.foldable._\n\nval items: List[CatsPriority] = List(High, Low, SuperHigh)\n\nitems.maximumOption // Some(SuperHigh)\n```\n\n#### Inheritance-free usage\nIf you need instances, but hesitate to mix in the traits demonstrated above, you can get them using the provided methods in `enumeratum.Cats` and `enumeratum.values.Cats` - the second also provides more flexibility than the (opinionated) mix-in trait as it allows to pass a custom type class instance for the value type (methods names are prefixed with `value`).\n\n## Doobie\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-doobie_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.beachape/enumeratum-doobie_2.12)\n\n### SBT\n\nTo use enumeratum with [Doobie](https://github.com/tpolecat/doobie):\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %% \"enumeratum-doobie\" % enumeratumDoobieVersion\n)\n```\n\nTo use with ScalaJS:\n\n```scala\nlibraryDependencies ++= Seq(\n    \"com.beachape\" %%% \"enumeratum-doobie\" % enumeratumDoobieVersion\n)\n```\n\n### Usage\n\n#### Enum\nIf you need to store enum values in text column of following table\n\n```sql\nCREATE TABLE clothes (\n  shirt varchar(100)\n)\n```\nyou should use following code\n```scala\nimport enumeratum._\n\nsealed trait ShirtSize extends EnumEntry\n\ncase object ShirtSize extends Enum[ShirtSize] with DoobieEnum[ShirtSize] {\n\n  case object Small  extends ShirtSize\n  case object Medium extends ShirtSize\n  case object Large  extends ShirtSize\n\n  val values = findValues\n\n}\n\ncase class Shirt(size: ShirtSize)\n\nimport doobie._\nimport doobie.implicits._\nimport doobie.util.ExecutionContexts\nimport cats.effect._\n\nimplicit val cs = IO.contextShift(ExecutionContexts.synchronous)\n\nval xa = Transactor.fromDriverManager[IO](\n  \"org.postgresql.Driver\",\n  \"jdbc:postgresql:world\",\n  \"postgres\",\n  \"\",\n  Blocker.liftExecutionContext(ExecutionContexts.synchronous)\n)\n\nsql\"insert into clothes (shirt) values (${Shirt(ShirtSize.Small)})\".update.run\n  .transact(xa)\n  .unsafeRunSync\n\nsql\"select shirt from clothes\"\n  .query[Shirt]\n  .to[List]\n  .transact(xa)\n  .unsafeRunSync\n  .take(5)\n  .foreach(println)\n```\n- Note that a type ascription to the `EnumEntry` trait (eg. `ShirtSize.Small: ShirtSize`) is required when binding hardcoded `EnumEntry`s\n\n#### ValueEnum\n\n```scala\nimport enumeratum.values.{ IntDoobieEnum, IntEnum, IntEnumEntry }\n\nsealed abstract class ShirtSize(val value: Int) extends IntEnumEntry\n\ncase object ShirtSize extends IntEnum[ShirtSize] with IntDoobieEnum[ShirtSize] {\n\n  case object Small  extends ShirtSize(1)\n  case object Medium extends ShirtSize(2)\n  case object Large  extends ShirtSize(3)\n\n  val values = findValues\n\n}\n\ncase class Shirt(size: ShirtSize)\n\nimport doobie._\nimport doobie.implicits._\nimport doobie.util.ExecutionContexts\nimport cats.effect._\n\nimplicit val cs = IO.contextShift(ExecutionContexts.synchronous)\n\nval xa = Transactor.fromDriverManager[IO](\n  \"org.postgresql.Driver\",\n  \"jdbc:postgresql:world\",\n  \"postgres\",\n  \"\",\n  Blocker.liftExecutionContext(ExecutionContexts.synchronous)\n)\n\nsql\"insert into clothes (shirt) values (${Shirt(ShirtSize.Small)})\".update.run\n  .transact(xa)\n  .unsafeRunSync\n\nsql\"select shirt from clothes\"\n  .query[Shirt]\n  .to[List]\n  .transact(xa)\n  .unsafeRunSync\n  .take(5)\n  .foreach(println)\n```\n- Note that a type ascription to the `ValueEnumEntry` abstract class (eg. `ShirtSize.Small: ShirtSize`) is required when binding hardcoded `ValueEnumEntry`s\n\n## Anorm\n\nAnorm provides a [module to support Enum](https://playframework.github.io/anorm/AnormEnumeratum.html) as `Column` and parameters.\n\n## Benchmarking\n\nBenchmarking is in the unpublished `benchmarking` project. It uses JMH and you can run them in the sbt console by issuing the following command from your command line:\n\n`sbt +benchmarking/'jmh:run -i 10 -wi 10 -f3 -t 1'`\n\nThe above command will run JMH benchmarks against different versions of Scala. Leave off `+` to run against the main/latest supported version of Scala.\n\nOn my late 2013 MBP using Java8 on OSX El Capitan:\n\n```\n[info] Benchmark                                            Mode  Cnt     Score    Error  Units\n[info] EnumBenchmarks.indexOf                               avgt   30    11.628 ±  0.190  ns/op\n[info] EnumBenchmarks.withNameDoesNotExist                  avgt   30  1809.194 ± 33.113  ns/op\n[info] EnumBenchmarks.withNameExists                        avgt   30    13.540 ±  0.374  ns/op\n[info] EnumBenchmarks.withNameOptionDoesNotExist            avgt   30     5.999 ±  0.037  ns/op\n[info] EnumBenchmarks.withNameOptionExists                  avgt   30     9.662 ±  0.232  ns/op\n[info] StdLibEnumBenchmarks.withNameDoesNotExist            avgt   30  1921.690 ± 78.898  ns/op\n[info] StdLibEnumBenchmarks.withNameExists                  avgt   30    56.517 ±  1.161  ns/op\n[info] values.ValueEnumBenchmarks.withValueDoesNotExist     avgt   30  1950.291 ± 29.292  ns/op\n[info] values.ValueEnumBenchmarks.withValueExists           avgt   30     4.009 ±  0.062  ns/op\n[info] values.ValueEnumBenchmarks.withValueOptDoesNotExist  avgt   30     5.285 ±  0.063  ns/op\n[info] values.ValueEnumBenchmarks.withValueOptExists        avgt   30     6.621 ±  0.084  ns/op\n```\n\n### Discussion\n\nOther than the methods that throw `NoSuchElementException`s, performance is in the 10ns range (taking into account JMH overhead of roughly 2-3ns), which\nis acceptable for almost all use-cases. PRs that promise to increase performance are expected to be demonstrably faster.\n\nAlso, Enumeratum's `withName` is faster than the standard library's `Enumeration`, by around 4x in the case where an entry exists with the given name.\nMy guess is this is because Enumeratum doesn't use any `synchronized` calls or `volatile` annotations. It is also faster in the case where there is no\ncorresponding name, but not by a significant amount, perhaps because the high cost of throwing an exception masks any benefits.\n\n## Publishing\n\nProjects are published independently of each other.\n\nJVM + ScalaJS projects should have an aggregate project to make it easy to publish them, e.g. for `enumeratum-circe`:\n\n`$ sbt \"project circe-aggregate\" +clean +publish-signed`\n\nShould publish all needed artefacts. Note that `sbt circe-aggregate/publish-signed` will not work (ScalaJS gets skipped).\n\n## Contributions\n\nIssues and PRs are more than welcome.\n\n* For bug fixes, enhancements, version bumps etc: please feel free to send a PR or issue\n* For _new_ integrations: these are generally bigger investments, and not all projects are a good fit to be maintained by me, so it would be a good idea to send an issue first to gauge interest and fit. If you feel it's a faster/better to have a concrete PR to discuss things with, by all means, feel free to go that route too.\n","funding_links":[],"categories":["Table of Contents","Extensions"],"sub_categories":["Extensions"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flloydmeta%2Fenumeratum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flloydmeta%2Fenumeratum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flloydmeta%2Fenumeratum/lists"}