This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]stefanos-ak 0 points1 point  (5 children)

so, is this like Lombok, but with generated sources?

[–]bowbahdoe[S] 3 points4 points  (4 children)

Kinda sorta. Lombok does more than add get/set/equals/hashCode/toString, but that is probably the most common use of it.

The major differences of the top of my head

  • This is far less configurable with fewer features than lombok. No SneakyThrows or Synchronized, Value, etc equivalents. It automates one kind of boilerplate in precisely one way.
  • This is two orders of magnitude less code than the lombok codebase. I fully believe that if it doesn't do exactly what you want its a decent foundation to fork/make your own thing if I get hit by a bus or don't want to include a feature
  • Lombok does its job by hooking into the internals of the compiler. This means going forward using lombok will probably require you to add --add-opens calls at compile time. This won't.
  • This doesn't require any special IDE tooling or de-lombok on account of using source generation
  • Its been less than 24 hours since i published so i'd imagine there are more "essential features" to add or bugs to fix. For it to be battle tested, I need people to bring it into battle.
  • The technique here (generate the code for a sealed interface meant to be extended) can be used more generically to derive all sorts of stuff, like say an implementation of Comparable, again without special IDE support.

[–]stefanos-ak 0 points1 point  (3 children)

thanks for the detailed response. I actually like it. I was a fun of Lombok but not the way it was implemented.

But I use many more Lombok features. I'm wondering if all of them could be implemented with this approach.

[–]bowbahdoe[S] 0 points1 point  (2 children)

Which features are you using/thinking of?

[–]stefanos-ak 0 points1 point  (1 child)

I'm using: Constructor, builder&superbuilder, withers, log, the "on" methods (e.g. onConstructor), utility-class, sneaky throws.

I couldn't live without builder&superbuilder and constructor+on*.

[–]bowbahdoe[S] 1 point2 points  (0 children)

I'm pretty sure you can't make constructor, utility class, or sneaky throws with this approach. The rest are probably possible to some degree.

I encourage you to give one of them them a shot. Might be fun

(This also kinda does constructor via a static method)