parent
63ccdeec16
commit
b1df13d4d4
221 changed files with 1528 additions and 1580 deletions
|
|
@ -70,16 +70,16 @@ package docs.serialization {
|
|||
// Use `""` if manifest is not needed.
|
||||
def manifest(obj: AnyRef): String =
|
||||
obj match {
|
||||
case _: Customer => CustomerManifest
|
||||
case _: User => UserManifest
|
||||
case _: Customer ⇒ CustomerManifest
|
||||
case _: User ⇒ UserManifest
|
||||
}
|
||||
|
||||
// "toBinary" serializes the given object to an Array of Bytes
|
||||
def toBinary(obj: AnyRef): Array[Byte] = {
|
||||
// Put the real code that serializes the object here
|
||||
obj match {
|
||||
case Customer(name) => name.getBytes(UTF_8)
|
||||
case User(name) => name.getBytes(UTF_8)
|
||||
case Customer(name) ⇒ name.getBytes(UTF_8)
|
||||
case User(name) ⇒ name.getBytes(UTF_8)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,9 +88,9 @@ package docs.serialization {
|
|||
def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
|
||||
// Put the real code that deserializes here
|
||||
manifest match {
|
||||
case CustomerManifest =>
|
||||
case CustomerManifest ⇒
|
||||
Customer(new String(bytes, UTF_8))
|
||||
case UserManifest =>
|
||||
case UserManifest ⇒
|
||||
User(new String(bytes, UTF_8))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue