Project Amber
Project Amber aims at bringing sealed classes and interfaces as well as records and the assorted features such as pattern matching to Java.
Articles in this category explore the design-space of applications in a world where Amber has been sucessfully implemented, including, but not limited to:
- pattern matching, with full deconstruction patterns, in
instanceof
&switch
let
binding with destructuring (deconstruction patterns)- Enhanced Enums (available via the
enhanced-enums
branch of Project Amber)
Resources
- Project Amber
- Enhanced Enums & JEP 301
- Concise method bodies
- Pattern matching for switch
this.x
binding of constructor parameters to reduce boilerplate in constructors
Articles
Record#with - a thought experiment
Recently, there were some interesting discussions about
Record#copy()
andRecord#with(...)
on theamber-spec-experts
mailing list (1, 2) which has lead me to implement both methods with a very clear & typesafe way, which I’d like to discuss below. The code demonstrated below is available as Gist.