Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement literals Reader and Writer #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package tethys.readers.instances

private[tethys] trait LiteralReaders
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package tethys.writers.instances

private[tethys] trait LiteralWriters
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package tethys.readers.instances

private[tethys] trait LiteralReaders {
implicit def booleanLiteralReader[L <: Boolean](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def stringLiteralReader[L <: String](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def shortLiteralReader[L <: Short](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def intLiteralReader[L <: Int](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def longLiteralReader[L <: Long](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def floatLiteralReader[L <: Float](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def doubleLiteralReader[L <: Double](implicit L: ValueOf[L]): JsonReader[L] = ???
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package tethys.writers.instances

private[tethys] trait LiteralWriters {
implicit def booleanLiteralReader[L <: Boolean](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def stringLiteralReader[L <: String](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def shortLiteralReader[L <: Short](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def intLiteralReader[L <: Int](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def longLiteralReader[L <: Long](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def floatLiteralReader[L <: Float](implicit L: ValueOf[L]): JsonReader[L] = ???

implicit def doubleLiteralReader[L <: Double](implicit L: ValueOf[L]): JsonReader[L] = ???
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tethys.JsonReader
import tethys.readers.tokens.TokenIterator
import tethys.readers.{FieldName, ReaderError}

trait AllJsonReaders extends OptionReaders {
trait AllJsonReaders extends LiteralReaders with OptionReaders {
implicit lazy val booleanReader: JsonReader[Boolean] = new JsonReader[Boolean] {
override def read(it: TokenIterator)(implicit fieldName: FieldName): Boolean = {
if(it.currentToken().isBooleanValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tethys.writers.instances
import tethys.JsonWriter
import tethys.writers.tokens.TokenWriter

trait AllJsonWriters extends OptionWriters {
trait AllJsonWriters extends LiteralWriters with OptionWriters {
implicit lazy val intWriter: JsonWriter[Int] = new JsonWriter[Int] {
override def write(value: Int, tokenWriter: TokenWriter): Unit = tokenWriter.writeNumber(value)
}
Expand Down