Skip to content

Instantly share code, notes, and snippets.

@bryanjswift
Created December 29, 2009 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanjswift/265154 to your computer and use it in GitHub Desktop.
Save bryanjswift/265154 to your computer and use it in GitHub Desktop.
trait User extends Credentials {
def credentials:WkCredentials
val uuid:Option[String]
val username:String = credentials.username
val password:String = credentials.password
val role:UserRole = credentials.role
val title:String = credentials.title
val active:Boolean = credentials.active
}
case class Credentials(
override val username:String,
override val password:String,
override val role:UserRole,
override val title:String,
override val active:Boolean,
uuid:Option[String]
) extends User {
def credentials = this
// TODO: In Scala 2.8.0 Delete this method
def cp(uuid:Option[String]):Credentials = Credentials(username,password,role,title,active,uuid)
def cp(pass:String):Credentials = Credentials(username,pass,role,title,active,uuid)
}
class Employee(
val contentInfo:ContentInfo, val credentials:Credentials, val personalInfo:PersonalInfo
) extends User with Person with Content {
private def canEqual(a:Any) = a.isInstanceOf[Employee]
// TODO: In Scala 2.8.0 Delete this method
def cp(uuid:Option[String]):Employee = Employee(contentInfo.cp(uuid),credentials.cp(uuid),personalInfo)
def cp(pass:String):Employee = Employee(contentInfo,credentials.cp(pass),personalInfo)
def equals(e:Employee) =
contentInfo == e.contentInfo && credentials == e.credentials && personalInfo == e.personalInfo
override def equals(q:Any) =
q match {
case that:Employee =>
canEqual(q) && equals(that)
case _ => false
}
override def hashCode =
41 * (41 * (41 + contentInfo.hashCode) + credentials.hashCode) + personalInfo.hashCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment