scala-news-reader
rss/atom news reader in scala
git clone https://9o.is/git/scala-news-reader.git
ObjectIdRefFieldExtra.scala
(657B)
1 package com.joereader.model.field
2
3 import org.bson.types._
4 import com.mongodb._
5 import net.liftweb._
6 import common._
7 import mongodb.record._
8 import field._
9
10 trait ObjectIdRefFieldExtra[
11 OwnerType <: BsonRecord[OwnerType],
12 RefType <: MongoRecord[RefType] with ObjectIdPk[RefType]]
13 extends ObjectIdRefField[OwnerType, RefType] {
14
15 override def defaultValue = new ObjectId("0" * 24)
16
17 def isEmpty: Boolean = get == defaultValue
18 def isDefined: Boolean = !isEmpty
19 def remove: OwnerType = this(defaultValue)
20
21 def is(a: RefType): Boolean = get == a.id.get
22 def is(a: Box[RefType]): Boolean = a.exists(is)
23 def isNot(a: RefType): Boolean = !is(a)
24 }