soabase / soabase-halva

Idiomatic Scala ... in Java
https://github.com/soabase/soabase-halva/blob/master/README.md
Apache License 2.0
81 stars 5 forks source link

Use enums for case objects #31

Closed azell closed 8 years ago

azell commented 8 years ago

Enums have certain advantages over vanilla classes:

It would be a simpler implementation to use an enum instead of a class for CaseObjects. I did a quick proof of concept and made the following changes:

  1. Named sole enum member the same as the enum to preserve existing usage and imports
  2. Removed Serializable from implements list
  3. Removed private constructor, equals and hashCode
  4. Removed static from method signatures and fields

Basic unit tests pass. Will try and put together a pull request though it is possible that this change may break existing clients.

Randgalt commented 8 years ago

It's early in the life of Halva so breaking changes aren't a big deal. I look forward to your PR.