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

com.xantoria.flippy.serialization..ConditionSerializer.scala.swp Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
b0VIM 7.4U??W?&?giftiger_wunschgiftig-fedora-desktop~giftiger_wunsch/Code/public/flippy/src/main/scala/com/xantoria/flippy/serialization/ConditionSerializer.scalautf-8
3210#"! Utpjdk?ad$?j????iGF???)(
?
?
?
?
-

??O3???????<!?
?
?
f
`
\
Z
Y
<

?	?	?	?	g	I	*		???plk$"!????dc????|ON?kICB??a ???ml????dP=??????  }    }    }      ))        JField("condition", Extraction.decompose(cond.inverted))        typeField,      JObject(List(      val cond = c.asInstanceOf[Condition.Not]    def serialize(c: Condition)(implicit formats: Formats): JValue = {    )      (data \ "condition").extract[Condition]    def deserialize(data: JValue)(implicit formats: Formats): Condition.Not = Condition.Not(    def canSerialize(c: Condition) = c.isInstanceOf[Condition.Not]    override val typeName: String = "not"  object Not extends ConditionSerializer[Condition.Not] {  }    }      JObject(List(typeField, JField("value", serializedValue)))      val serializedValue: JValue = Extraction.decompose(new ContextValue(cond.requiredValue))      val cond = c.asInstanceOf[Condition.Equals]    override def serialize(c: Condition)(implicit formats: Formats): JValue = {    }      new Condition.Equals(value)      val value: Any = (data \ "value").extract[ContextValue].underlying    def deserialize(data: JValue)(implicit formats: Formats): Condition.Equals = {    def canSerialize(c: Condition) = c.isInstanceOf[Condition.Equals]    override val typeName: String = "equals"  object Equals extends ConditionSerializer[Condition.Equals] {object ConditionSerializer {}  def deserialize(data: JValue)(implicit formats: Formats): T  def serialize(condition: Condition)(implicit formats: Formats): JValue  def canSerialize(condition: Condition): Boolean  def typeField = JField("condition_type", JString(typeName))  val typeName: Stringabstract class ConditionSerializer[T <: Condition] {}  def apply(): SerializationEngine = new SerializationEngine(DEFAULTS)  )    NetworkingSerializer.IPRange    StringConditionSerializers.Substring,    StringConditionSerializers.Regex,    StringConditionSerializers.Range,    NamespacedConditionSerializer,    ConditionSerializer.False,    ConditionSerializer.True,    ConditionSerializer.Proportion,    ConditionSerializer.Or,    ConditionSerializer.Not,    ConditionSerializer.Equals,    ConditionSerializer.And,  final val DEFAULTS: List[ConditionSerializer[_]] = List(object SerializationEngine {}  }    }      serializer.serialize(c)      }        throw new UnsupportedConditionTypeException(c.getClass.getName)      val serializer = conditionTypes.find { _.canSerialize(c) }.getOrElse {    case c: Condition => {  def serialize(implicit formats: Formats): PartialFunction[Any, JValue] = {  }    }      concrete.deserialize(data).asInstanceOf[Condition]      }        throw new UnsupportedConditionTypeException(desiredType.getOrElse("none specified"))      }.flatten getOrElse {        desired: String => conditionTypes.find { _.typeName == desired }      val concrete = desiredType.map {      val desiredType = (data \ "condition_type").extractOpt[String]    case (TypeInfo(Class, _), data) => {  def deserialize(implicit formats: Formats): PartialFunction[(TypeInfo, JValue), Condition] = {  private val Class = classOf[Condition]) extends Serializer[Condition] {  val conditionTypes: List[ConditionSerializer[_]]class SerializationEngine(class UnsupportedConditionTypeException(condType: String) extends RuntimeException(condType)class MalformedConditionDefinitionException(msg: String) extends RuntimeException(msg)import com.xantoria.flippy.condition.NamespacedConditionimport com.xantoria.flippy.condition.Conditionimport net.liftweb.json.JsonAST._import net.liftweb.json.{Extraction, Formats, Serializer, ShortTypeHints, TypeInfo}import scala.reflect._package com.xantoria.flippy.serializationad?
<?~zy4???xIB><;}  }    ))      JField("fallback", JBool(cond.fallback))      JField("condition", Extraction.decompose(cond.cond)),      JField("attr", JString(cond.attr)),      typeField,    JObject(List(    val cond = c.asInstanceOf[NamespacedCondition]  def serialize(c: Condition)(implicit formats: Formats): JValue = {  }    new NamespacedCondition(attr, condition, fallback)    val fallback = (data \ "fallback").extractOpt[Boolean] getOrElse falsead*?d???XW??? ?
?
?
x
r
q
*
????{uqp8??|0	?
?
?
n


?	?	?	?	t	`	M	??????po%$??uon'????????N#"???1-,?????2????uFE???k??    val condition = (data \ "condition").extract[Condition]    }      throw new MalformedConditionDefinitionException("[Namespace] Missing attr!")    val attr = (data \ "attr").extractOpt[String] getOrElse {  def deserialize(data: JValue)(implicit formats: Formats): NamespacedCondition = {  def canSerialize(c: Condition) = c.isInstanceOf[NamespacedCondition]  override val typeName: String = "namespaced"object NamespacedConditionSerializer extends ConditionSerializer[NamespacedCondition] {}  }    def serialize(c: Condition)(implicit formats: Formats): JValue = JObject(List(typeField))    def deserialize(data: JValue)(implicit formats: Formats): Condition = Condition.False    def canSerialize(c: Condition) = c == Condition.False    override val typeName: String = "false"  object False extends ConditionSerializer[Condition] {  }    def serialize(c: Condition)(implicit formats: Formats): JValue = JObject(List(typeField))    def deserialize(data: JValue)(implicit formats: Formats): Condition = Condition.True    def canSerialize(c: Condition) = c == Condition.True    override val typeName: String = "true"  object True extends ConditionSerializer[Condition] {  }    }      ))        JField("proportion", JDouble(cond.prop))        typeField,      JObject(List(      val cond = c.asInstanceOf[Condition.Proportion]    def serialize(c: Condition)(implicit formats: Formats): JValue = {    }      Condition.Proportion(prop)      val prop = (data \ "proportion").extract[Double]    def deserialize(data: JValue)(implicit formats: Formats): Condition.Proportion = {    def canSerialize(c: Condition) = c.isInstanceOf[Condition.Proportion]    override val typeName: String = "proportion"  object Proportion extends ConditionSerializer[Condition.Proportion] {  }    }      ))        JField("conditions", JArray(cond.subs map { Extraction.decompose(_) }))        typeField,      JObject(List(      val cond = c.asInstanceOf[Condition.Or]    def serialize(c: Condition)(implicit formats: Formats): JValue = {    }      Condition.Or(conditions)      }        throw new MalformedConditionDefinitionException("[Or] No conditions provided")      if (conditions.isEmpty) {      }        throw new MalformedConditionDefinitionException("[Or] Missing 'conditions' attribute")      } getOrElse {        _.map { _.extract[Condition] }      val conditions = (data \ "conditions").extractOpt[List[JValue]] map {    def deserialize(data: JValue)(implicit formats: Formats): Condition.Or = {    def canSerialize(c: Condition) = c.isInstanceOf[Condition.Or]    override val typeName: String = "or"  object Or extends ConditionSerializer[Condition.Or] {  }    }      ))        JField("conditions", JArray(cond.subs map { Extraction.decompose(_) }))        typeField,      JObject(List(      val cond = c.asInstanceOf[Condition.And]    def serialize(c: Condition)(implicit formats: Formats): JValue = {    }      Condition.And(conditions)      }        throw new MalformedConditionDefinitionException("[And] No conditions provided")      if (conditions.isEmpty) {      }        throw new MalformedConditionDefinitionException("[And] Missing 'conditions' attribute")      } getOrElse {        _.map { _.extract[Condition] }      val conditions = (data \ "conditions").extractOpt[List[JValue]] map {    def deserialize(data: JValue)(implicit formats: Formats): Condition.And = {    def canSerialize(c: Condition) = c.isInstanceOf[Condition.And]    override val typeName: String = "and"  object And extends ConditionSerializer[Condition.And] {




© 2015 - 2024 Weber Informatics LLC | Privacy Policy