Giter Club home page Giter Club logo

Comments (5)

lloydmeta avatar lloydmeta commented on July 17, 2024

Can you expand a little bit on what you mean by avoiding the overhead of overriding value? Current usage looks quite similar to what you've got there.

sealed abstract class LibraryItem(val value: Int, val name: String) extends IntEnumEntry

from enumeratum.

bertderbecker avatar bertderbecker commented on July 17, 2024

Currently, i have to override the method value:

sealed abstract class LibraryItem(val value: Int, val name: String) extends IntEnumEntry {
  override def value: Int = code
}

What I propose is a macro annotation for the parameter:

sealed abstract class Code(@Value val value: Int, val door: String) extends IntEnumEntry

Here it's not necessary to override the value method...

from enumeratum.

lloydmeta avatar lloydmeta commented on July 17, 2024

Currently, i have to override the method value:

sealed abstract class LibraryItem(val value: Int, val name: String) extends IntEnumEntry {
  override def value: Int = code
}

What I propose is a macro annotation for the parameter:

sealed abstract class Code(@Value val value: Int, val door: String) extends IntEnumEntry

Here it's not necessary to override the value method...

Just to make sure I understand fully what you mean, you probably have this situation right now:

sealed abstract class LibraryItem(val code: Int, val name: String) extends IntEnumEntry {
  override def value: Int = code
}

and what you want is

sealed abstract class Code(@Value val code: Int, val door: String) extends IntEnumEntry

?

from enumeratum.

bertderbecker avatar bertderbecker commented on July 17, 2024

Exactly! :)

from enumeratum.

lloydmeta avatar lloydmeta commented on July 17, 2024

I think it's do-able, but maybe it's a nice-to-have. Also, I don't think there's going to be much actual runtime performance overhead to the alias method once JIT kicks in.

If you would like to contribute this feature, please feel free to give it a try :) My only request is that it be done without adding dependencies and that error cases be handled nicely !

from enumeratum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.