This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PersonBuilder._ | |
import shapeless._ | |
case class Person(name: String, age: Int) | |
object PersonBuilder { | |
def apply() = new PersonBuilder[Start](Person("", 0)) | |
trait Start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonBuilder { | |
public PersonBuilder() { | |
} | |
public StepAge name(String name) { | |
return new StepAge(new Person(name, -1)); | |
} | |
public class StepAge { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
private String name; | |
private int age; | |
public Person(String name, int age) { | |
this.name = name; | |
this.age = age; | |
} | |
public String getName() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object PlayJsonWritesDerivation { | |
type Typeclass[T] = Writes[T] | |
def combine[T](ctx: CaseClass[Writes, T]): Writes[T] = | |
new Writes[T] { | |
override def writes(o: T): JsValue = | |
JsObject(ctx.parameters.map { | |
param => | |
(param.label, param.typeclass.writes(param.dereference(o))) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.Future | |
import scala.util.Try | |
import For.typeMaps._ | |
import For.typeUnits._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.Await | |
import scala.language.implicitConversions |