patriknw / kaze-class

Like Case Class, but easier to bin-compat evolve

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kaze Class

Build Status

Yet another "like case class but easier to evolve in binary compatible way" source code generator.

Specific use case: when configuration objects where prototyped during experimental phase of a project using case classes, and now need to be made stable API, thus generate sadly often having to resign from using case classes – this project takes a Class[T] and generates a KazeClass from it, which is nothing else than a string representation of a "manual implementation" of the most basic features of case clases.

A KazeClass uses identity equality (not structural equality), be aware of that.

Naming

Kaze (風) means "wind" or "movement of air" in Japanese, which reminded me of how we wanted to swiftly, and unhindered–like the wind–evolve these classes.

Usage

Get the jar or copy&paste the KazeClass into your project, then call:

val rendered: String = KazeClass.of[Person].render

to get a "desugared" case class, ready to replace your case class.

Here is an example output.

Goals / Non-Goals

Goal:

  • One of the goals is to be able to just paste this one class (or include in REPL) to generate the source. It must be small, trivial even, and have zero dependencies.

Non-Goal:

  • Actually become a big fancy project that solves all things regarding helping evolve the classes. Multiple people have attempted that, and eventually it always breaks down on some edge cases (or plain lack of time), thus this code generator is dead simple and proud to be so.
  • Cover all edge cases of what might go wrong, minor manual interaction is acceptable (feel free to submit PRs to minimize those though).

License

Apache 2.0

About

Like Case Class, but easier to bin-compat evolve

License:Apache License 2.0


Languages

Language:Scala 100.0%