scala try

Ruby code posted by zhitko
created at 03 Oct 12:05, updated at 03 Oct 12:07

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
case class IslandAttachContent(
                                id: Option[Long]
                                , parentId: Option[Long]
                                , visibility: VisibilityObject
                                , userId: Option[Long]
                                , created: Option[DateTime]
                                , modified: Option[DateTime]
                                , islandContentType: ContentType
                                , url: Option[String]
                                , name: Option[String]
                                , body: Option[String]
                                , description: Option[String]
                                , resourceType: Option[String]
                                , thumbnail: Option[String]
                                , providerName: Option[String]
                                , providerUrl: Option[String]
                                , published: Option[DateTime]
                                , islandAliasId: Option[String] = None
                                , categoryId: Option[Long] = None
                                , groupId: Option[Long] = None
                                )
trait IslandAttachContentJsonConversion
  extends IdentityLongOps
  with DateTimeJsonConversion
{
  import play.api.libs.functional.syntax._
  import play.api.libs.json._

  implicit val IslandAttachContentValidator = new IslandAttachContentValidator
  implicit val IslandAttachContentListValidator = new JsonValidator[List[IslandAttachContent]]{}
  implicit val IslandAttachContentSeqValidator = new JsonValidator[Seq[IslandAttachContent]]{}
  implicit val IslandAttachContentOptValidator = new JsonValidator[Option[IslandAttachContent]]{}

  implicit val IslandAttachContentFormatter: Format[IslandAttachContent] = (
    (__   \ "id").formatNullable[Long]
      ~ (__ \ "parent_id").formatNullable[Long]
      ~ (__ \ "visibility").format[VisibilityObject]
      ~ (__ \ "user_id").formatNullable[Long]
      ~ (__ \ "created").formatNullable[DateTime]
      ~ (__ \ "modified").formatNullable[DateTime]
      ~ (__ \ "type").format[ContentType]
      ~ (__ \ "url").formatNullable[String]
      ~ (__ \ "name").formatNullable[String]
      ~ (__ \ "body").formatNullable[String]
      ~ (__ \ "description").formatNullable[String]
      ~ (__ \ "resource_type").formatNullable[String]
      ~ (__ \ "thumbnail").formatNullable[String]
      ~ (__ \ "provider_name").formatNullable[String]
      ~ (__ \ "provider_url").formatNullable[String]
      ~ (__ \ "published").formatNullable[DateTime]
      ~ (__ \ "islandAliasId").formatNullable[String]
      ~ (__ \ "categoryId").formatNullable[Long]
      ~ (__ \ "groupId").formatNullable[Long]
    )(IslandAttachContent.apply, unlift(IslandAttachContent.unapply))

  implicit val IslandAttachContentListReader = Reads.list[IslandAttachContent](IslandAttachContentFormatter)
  implicit val IslandAttachContentSeqReader = Reads.seq[IslandAttachContent](IslandAttachContentFormatter)

  implicit val IslandAttachContentListWriter = Writes.list[IslandAttachContent](IslandAttachContentFormatter)
  implicit val IslandAttachContentSeqWriter = Writes.seq[IslandAttachContent](IslandAttachContentFormatter)

}
3.25 KB in 4 ms with coderay