diff options
author | Mathias <mathias@spray.cc> | 2011-10-04 09:40:35 +0200 |
---|---|---|
committer | Mathias <mathias@spray.cc> | 2011-10-04 09:45:46 +0200 |
commit | 24af701d7e3bce6f72bb8b2f12c6099f3d85403f (patch) | |
tree | bd917afb03aed008edaf55058f65e79b0cfea118 /src/main/scala/cc/spray/json/AdditionalFormats.scala | |
parent | 758e17d8c780ab44befc26a18344367f70334c56 (diff) | |
download | spray-json-24af701d7e3bce6f72bb8b2f12c6099f3d85403f.tar.gz spray-json-24af701d7e3bce6f72bb8b2f12c6099f3d85403f.tar.bz2 spray-json-24af701d7e3bce6f72bb8b2f12c6099f3d85403f.zip |
Improve some scaladoc comments
Diffstat (limited to 'src/main/scala/cc/spray/json/AdditionalFormats.scala')
-rw-r--r-- | src/main/scala/cc/spray/json/AdditionalFormats.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/scala/cc/spray/json/AdditionalFormats.scala b/src/main/scala/cc/spray/json/AdditionalFormats.scala index e8b59c7..db9d3ba 100644 --- a/src/main/scala/cc/spray/json/AdditionalFormats.scala +++ b/src/main/scala/cc/spray/json/AdditionalFormats.scala @@ -27,17 +27,26 @@ trait AdditionalFormats { def read(value: JsValue) = value } + /** + * Constructs a JsonFormat from its two parts, JsonReader and JsonWriter. + */ def jsonFormat[T](reader: JsonReader[T], writer: JsonWriter[T]) = new JsonFormat[T] { def write(obj: T) = writer.write(obj) def read(json: JsValue) = reader.read(json) } + /** + * Turns a JsonWriter into a JsonFormat that throws an UnsupportedOperationException for reads. + */ def lift[T](writer :JsonWriter[T]) = new JsonFormat[T] { def write(obj: T): JsValue = writer.write(obj) def read(value: JsValue) = throw new UnsupportedOperationException("JsonReader implementation missing") } + /** + * Turns a JsonReader into a JsonFormat that throws an UnsupportedOperationException for writes. + */ def lift[T <: AnyRef](reader :JsonReader[T]) = new JsonFormat[T] { def write(obj: T): JsValue = throw new UnsupportedOperationException("No JsonWriter[" + obj.getClass + "] available") |