All Downloads are FREE. Search and download functionalities are using the official Maven repository.

encrywm.backend.env.ESObject.scala Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package encrywm.backend.env

import encrywm.lib.Types.{ESProduct, ESType}

case class ESObject(name: String,
                    attrs: Map[String, ESValue],
                    tpe: ESProduct) extends ESEnvComponent {

  def getAttr(n: String): Option[ESValue] = attrs.get(n)

  def isInstanceOf(t: ESType): Boolean = t match {
    case p: ESProduct => this.name == p.ident && (this.tpe == p || this.tpe.isSubtypeOf(p))
    case _ => false
  }

  override def equals(obj: scala.Any): Boolean = obj match {
    case ESObject(thatName, thatAttrs, _) =>
      thatName == this.name && thatAttrs.zip(this.attrs).forall { case ((_, v1), (_, v2)) => v1 == v2 }
    case _ => false
  }
}

object ESObject {
  val typeId: Byte = 0.toByte
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy